Calling console app (dtexec) from windows service

A

asadikhan

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("strDTExecPath: " + strDTExecPath);
log.Info("strPackageName: " + strPackageName);
try
{
log.Info("Starting");
System.Diagnostics.Process.Start(strDTExecPath,
strPackageName);
log.Info("Finishing");
}
catch (Exception ex)
{
log.Error(ex.ToString());
return false;
}
return true;
}

Client Side:

static void Main(string[] args)
{
try
{
string strURLRemoteClass =
ConfigurationSettings.AppSettings["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
TcpClientChannel channel = new TcpClientChannel();
ChannelServices.RegisterChannel(channel);
// Step 2: Register the remote class as a valid type
// in the client's application domain
RemotingConfiguration.RegisterWellKnownClientType(
typeof(DTExec),
strURLRemoteClass);
// Step 3: Instantiate the remote class
objDTExec = new DTExec();

if (objDTExec.Execute(strPackageName))
log.Info("Success");
else
log.Info("Failure");
}
catch (Exception ex)
{
log.Info(ex.ToString());
}
}

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\Learning\Test\Test\bin\Debug\Test.exe
2007-01-22 15:13:19,773 [4624] INFO DTExecServerLog [Execute:0] -
strDTExecPath: C:\...\Visual Studio
2005\Projects\Learning\Test\Test\bin\Debug\Test.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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top