PC Review


Reply
Thread Tools Rate Thread

Access Console Application from Managed Code

 
 
Will Asrari
Guest
Posts: n/a
 
      20th Jun 2006
I am working on a project now for a client that requires all managed code.
I have rewritten about 60% of the code and functionality in C# and have now
come to the complicated part of picking apart the existing stored procedure
and "managing" it. Two tasks that I am outing from the stored procedure are
as follows:

1) execution of a .vbs that creates a .txt file (CSV) of user information
2) loading of said text file into an .exe and executing via command line

I can achieve the same result as 1 with a streamwriter. This shouldn't be
too complicated. Number 2 is what I am worried about. The .exe will reside
on the same server where my application exists. What would be the best way
to accomplish this task in a managed way?

I tried opening the exe on the server by double-clicking it and got the
following error:

"%E: Cannot find "\Ent=' parameter on the command line."

So there is no GUI. It seems as if this is a simple console application.

Here is the line from the old stored procedure:

SET @LaunchImportString = '\\' + @AppServer +
'\applicationName\sys_exe\ga_imp2.exe /GO /Ent=' + cast(@EntID as
varchar(20)) + ' /Store=1'
exec master..xp_cmdshell @LaunchImportString, no_output

Since I wasn't the original author of this software I don't know all of the
code. I do know that I'm not going to use SQL server to access the command
line.

Thanks in advance,

- Will


 
Reply With Quote
 
 
 
 
Nicholas Paldino [.NET/C# MVP]
Guest
Posts: n/a
 
      20th Jun 2006
Will,

Basically, you will want to call the static Start method on the Process
class. Create a variable which would be the same as @LaunchImportString and
then pass that to the method.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (E-Mail Removed)


"Will Asrari" <news[at]willasrari.comNOSPAM> wrote in message
news:%(E-Mail Removed)...
>I am working on a project now for a client that requires all managed code.
>I have rewritten about 60% of the code and functionality in C# and have now
>come to the complicated part of picking apart the existing stored procedure
>and "managing" it. Two tasks that I am outing from the stored procedure
>are as follows:
>
> 1) execution of a .vbs that creates a .txt file (CSV) of user information
> 2) loading of said text file into an .exe and executing via command line
>
> I can achieve the same result as 1 with a streamwriter. This shouldn't be
> too complicated. Number 2 is what I am worried about. The .exe will
> reside on the same server where my application exists. What would be the
> best way to accomplish this task in a managed way?
>
> I tried opening the exe on the server by double-clicking it and got the
> following error:
>
> "%E: Cannot find "\Ent=' parameter on the command line."
>
> So there is no GUI. It seems as if this is a simple console application.
>
> Here is the line from the old stored procedure:
>
> SET @LaunchImportString = '\\' + @AppServer +
> '\applicationName\sys_exe\ga_imp2.exe /GO /Ent=' + cast(@EntID as
> varchar(20)) + ' /Store=1'
> exec master..xp_cmdshell @LaunchImportString, no_output
>
> Since I wasn't the original author of this software I don't know all of
> the code. I do know that I'm not going to use SQL server to access the
> command line.
>
> Thanks in advance,
>
> - Will
>



 
Reply With Quote
 
Michael Cummings
Guest
Posts: n/a
 
      20th Jun 2006
The following snippet (untested) should be relatively close to what your
looking to do:


System.Diagnostics.Process proc = new System.Diagnostics.Process();
proc.EnableRaisingEvents = false;
proc.StartInfo.Arguments = @"/GO /Ent=" + EntID + @"/Store=1";
proc.StartInfo.WorkingDirectory = @"\\" + AppServer +
@"\applicationName\sys_exe";
proc.StartInfo.FileName = "ga_imp2.exe";
proc.Start();


Michael Cummings
michaelc AT magenic DOT com
Magenic Technologies

"Will Asrari" <news[at]willasrari.comNOSPAM> wrote in message
news:%(E-Mail Removed)...
>I am working on a project now for a client that requires all managed code.
>I have rewritten about 60% of the code and functionality in C# and have now
>come to the complicated part of picking apart the existing stored procedure
>and "managing" it. Two tasks that I am outing from the stored procedure
>are as follows:
>
> 1) execution of a .vbs that creates a .txt file (CSV) of user information
> 2) loading of said text file into an .exe and executing via command line
>
> I can achieve the same result as 1 with a streamwriter. This shouldn't be
> too complicated. Number 2 is what I am worried about. The .exe will
> reside on the same server where my application exists. What would be the
> best way to accomplish this task in a managed way?
>
> I tried opening the exe on the server by double-clicking it and got the
> following error:
>
> "%E: Cannot find "\Ent=' parameter on the command line."
>
> So there is no GUI. It seems as if this is a simple console application.
>
> Here is the line from the old stored procedure:
>
> SET @LaunchImportString = '\\' + @AppServer +
> '\applicationName\sys_exe\ga_imp2.exe /GO /Ent=' + cast(@EntID as
> varchar(20)) + ' /Store=1'
> exec master..xp_cmdshell @LaunchImportString, no_output
>
> Since I wasn't the original author of this software I don't know all of
> the code. I do know that I'm not going to use SQL server to access the
> command line.
>
> Thanks in advance,
>
> - Will
>



 
Reply With Quote
 
Will Asrari
Guest
Posts: n/a
 
      20th Jun 2006
Thanks to both of you for your input. I will test this hopefully later this
week.

- Will


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Access Console Application from Managed Code Will Asrari Microsoft ASP .NET 3 20th Jun 2006 06:14 PM
Access Console Application from Managed Code Will Asrari Microsoft Dot NET Framework 3 20th Jun 2006 06:14 PM
Access Console Application from Managed Code Will Asrari Microsoft Dot NET 3 20th Jun 2006 06:14 PM
Using static Library from application written with managed code chandra.somesh@gmail.com Microsoft Dot NET Compact Framework 3 10th Feb 2006 09:49 PM
Service containing managed code aborts on logout from console =?Utf-8?B?U3RldmUgQ3Jvc3NsZXk=?= Microsoft Dot NET Framework 0 24th Feb 2005 08:07 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:13 PM.