473,785 Members | 2,807 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Calling console app (dtexec) from windows service

I need to call a console app (dtexec) from a windows service in a
client/server architecture. I have the application setup so that the
client application is called with a package name, which makes a call to
a dll on the remote server. I have read up on this on the web and I
know that you can't run a GUI app from within windows service, but
apparently console apps are ok. I am trying exactly that but it's not
working. Here is my code:

Server side:

public bool Execute(string strPackageName)
{
log.Info("strDT ExecPath: " + strDTExecPath);
log.Info("strPa ckageName: " + strPackageName) ;
try
{
log.Info("Start ing");
System.Diagnost ics.Process.Sta rt(strDTExecPat h,
strPackageName) ;
log.Info("Finis hing");
}
catch (Exception ex)
{
log.Error(ex.To String());
return false;
}
return true;
}

Client Side:

static void Main(string[] args)
{
try
{
string strURLRemoteCla ss =
ConfigurationSe ttings.AppSetti ngs["URLRemoteClass "];
string strPackageName = args[0].Trim();
if (strPackageName .Length <= 0)
{
log.Info("No package name provided in the
arguments.");
return;
}
// Step 1: Register a TCP client channel
TcpClientChanne l channel = new TcpClientChanne l();
ChannelServices .RegisterChanne l(channel);
// Step 2: Register the remote class as a valid type
// in the client's application domain
RemotingConfigu ration.Register WellKnownClient Type(
typeof(DTExec),
strURLRemoteCla ss);
// Step 3: Instantiate the remote class
objDTExec = new DTExec();

if (objDTExec.Exec ute(strPackageN ame))
log.Info("Succe ss");
else
log.Info("Failu re");
}
catch (Exception ex)
{
log.Info(ex.ToS tring());
}
}

No errors are logged on either side. In the server log file I get this:
2007-01-22 15:13:19,763 [4624] INFO DTExecServerLog [.ctor:0] -
strDTExecPath: C:\...\Visual Studio
2005\Projects\L earning\Test\Te st\bin\Debug\Te st.exe
2007-01-22 15:13:19,773 [4624] INFO DTExecServerLog [Execute:0] -
strDTExecPath: C:\...\Visual Studio
2005\Projects\L earning\Test\Te st\bin\Debug\Te st.exe
2007-01-22 15:13:19,773 [4624] INFO DTExecServerLog [Execute:0] -
strPackageName: C:\foo.txt
2007-01-22 15:13:19,773 [4624] INFO DTExecServerLog [Execute:0] -
Starting
2007-01-22 15:13:19,844 [4624] INFO DTExecServerLog [Execute:0] -
Finishing
Any ideas as to what I am doing wrong?

Any comments on how we can run DTEXEC remotely without having to
install anything additional on the workstation are also welcomed.

Jan 22 '07 #1
0 3486

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
3388
by: Samuel R. Neff | last post by:
We're using a 3rd party C DLL in a project that we don't have source for. When we call the DLL from a console app everything works fine. However, when we call it from a Windows Service, the DLL doesn't work (sorry, can't be more descriptive.. no errors, but no results). We've even taken the exact Windows Service project and put code in main() to instantiate the service and call OnStart() instead of going through the service base class. ...
3
1970
by: Dean Slindee | last post by:
I have a exception handling class that could be called from either a windows project app or a console project app. Is there any way for this class to determine which type of app called it without sending an window/console parameter from either app? Thanks, Dean Slindee
0
1366
by: han zhiyang | last post by:
I've just studied the "how to" web service and the async pattern in donnet.I make a test with these knowledges,but I got a strange result. Here is my test. 1.Write a simple "Add" service named MathWS( the class name),and put it in a ..asmx file named math.asmx in the "D:/winnt/interpub/wwwroot/mathws" directory. "mathws" is my new-built directory. 2.run the http://localhost/mathws/math.asmx,find it works well,and run run the...
3
2327
by: JohnH | last post by:
Does any one now how to create a .net service thet when run from the command line with say a -D argument will run as a console app and be able to output to that console window. The same .exe would start as a normal service wihout the -D argument and require use of the NET START command or other.
5
8389
by: Jon Davis | last post by:
Is there such a thing as a Windows standard for killing a console app that is monitored by a System.Diagnostics.Process object? I'm hosting several C# console apps in a C# Windows service and would like to standardize on a graceful termination method when the Windows service stops. Jon
1
1851
by: Joe | last post by:
Is it possible? I have a 3rd party app which repeatedly calls a console app and in order to speed things up I thought it would be better to have the consoles functionality contained within a windows service. The problem I face is getting the third party app to call into the service and I was wondering if there was any way that it could call a bat file or some other scripting language that would then call the service. It passes simple...
12
6543
by: Dilip | last post by:
Hi All I have a server based C# console application. This application must hide its console window when its launched out on the field. So I dutifully P/Invoke'd FindWindow/ShowWindow combination to hide the console window at launch time. The application (for legacy reasons) hangs around by waiting on an old- fashioned Console.ReadLine() statement.
15
8211
by: =?Utf-8?B?VG9tIENvcmNvcmFu?= | last post by:
I've been led to believe by several articles, particularly Eric Gunnerson's C# Calling Code Dynamically, that calling a method dynamically through Reflection was much slower than through a Delegate. My testing showed that actually it was six times faster: 0.5 seconds for 100,000 iterations versus 3.1 seconds. Can anyone explain why? Something in the way I coded it? I'd appreciate any insights. Here's the code (in a Windows Form...
1
2038
by: samdediacre | last post by:
Hi all, I have developped a very simple Windows service that references a managed .NET dll. the code within the dll contains a static class to read/write data from registry. So the OnStart() method of the service simply calls the dll to read info from registry, but the static method reading info fails to execute... the dll tested within a console or winform application works fine (i can call the static class and get the info i want) So i...
0
9645
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9480
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10329
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10152
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10092
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9950
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5381
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3650
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.