By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,888 Members | 1,236 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,888 IT Pros & Developers. It's quick & easy.

Calling console app (dtexec) from windows service

P: n/a
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.ex e
2007-01-22 15:13:19,773 [4624] INFO DTExecServerLog [Execute:0] -
strDTExecPath: C:\...\Visual Studio
2005\Projects\Learning\Test\Test\bin\Debug\Test.ex e
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
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.