473,385 Members | 1,876 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Access Console Application from Managed Code

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
Jun 20 '06 #1
3 1223
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]
- mv*@spam.guard.caspershouse.com
"Will Asrari" <news[at]willasrari.comNOSPAM> wrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
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

Jun 20 '06 #2
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:%2****************@TK2MSFTNGP03.phx.gbl...
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

Jun 20 '06 #3
Thanks to both of you for your input. I will test this hopefully later this
week.

- Will
Jun 20 '06 #4

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

Similar topics

9
by: | last post by:
Hi All, I have allready tried to ask a similar question , but got no answer until now. In the meantime, I found, that I cannot understand some thread-settings for the Main() function . If I use...
1
by: BillyO | last post by:
In the attached code fragment I have a buffer overflow and a memory access violation. When I run the code .Net fails to verify the IL because of the buffer overflow and I get an exception as...
7
by: Bonj | last post by:
Hi I have a mixed managed/unmanaged project which thanks to you guys I've managed to get rid of the linker errors of, so cheers for that. But now I'm experiencing an unknown access violation....
29
by: Patrick | last post by:
I have the following code, which regardless which works fine and logs to the EventViewer regardless of whether <processModel/> section of machine.config is set to username="SYSTEM" or "machine" ...
0
by: Maxwell | last post by:
Hello, I recently completed a MC++ (VS2003) DLL that wraps a non MFC C++ DLL and need to use it in a MC++ Console Application (no forms/guis of any kind just output to console). Trouble is...
1
by: lactaseman | last post by:
While I know this is not the correct venue... I realize this is of little to no importance to most out there... however, if I had found this in my initial searches, I would have used this. So, as...
3
by: Will Asrari | last post by:
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...
3
by: Sune | last post by:
Hi all, I'm not a C# programmer so please be gentle: Prereq: --------------- - The lookup service (see below) implemented by a C module cannot be re-written in C# ;-) - The lookup service...
7
by: Ashutosh Bhawasinka | last post by:
Hi, I have a C# .Net application which needs to use some feature which can be only developed in Visual C++ (its extended MAPI). The C# exe will be supplied to users without a setup. What kind...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.