473,782 Members | 2,485 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 @LaunchImportSt ring = '\\' + @AppServer +
'\applicationNa me\sys_exe\ga_i mp2.exe /GO /Ent=' + cast(@EntID as
varchar(20)) + ' /Store=1'
exec master..xp_cmds hell @LaunchImportSt ring, 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 1244
Will,

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

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m
"Will Asrari" <news[at]willasrari.comN OSPAM> wrote in message
news:%2******** ********@TK2MSF TNGP03.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 @LaunchImportSt ring = '\\' + @AppServer +
'\applicationNa me\sys_exe\ga_i mp2.exe /GO /Ent=' + cast(@EntID as
varchar(20)) + ' /Store=1'
exec master..xp_cmds hell @LaunchImportSt ring, 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.Diagnost ics.Process proc = new System.Diagnost ics.Process();
proc.EnableRais ingEvents = false;
proc.StartInfo. Arguments = @"/GO /Ent=" + EntID + @"/Store=1";
proc.StartInfo. WorkingDirector y = @"\\" + AppServer +
@"\applicationN ame\sys_exe";
proc.StartInfo. FileName = "ga_imp2.ex e";
proc.Start();
Michael Cummings
michaelc AT magenic DOT com
Magenic Technologies

"Will Asrari" <news[at]willasrari.comN OSPAM> wrote in message
news:%2******** ********@TK2MSF TNGP03.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 @LaunchImportSt ring = '\\' + @AppServer +
'\applicationNa me\sys_exe\ga_i mp2.exe /GO /Ent=' + cast(@EntID as
varchar(20)) + ' /Store=1'
exec master..xp_cmds hell @LaunchImportSt ring, 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
6331
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 the attribute for the Main() function, I get "access denied error", if I use a ManagementEventWatcher to connect to the local machine to receive events. Is there anybody out there, how possibly can explain why this happens?? If I remove this...
1
2467
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 expected. My question relates to the memory access violation, specfically, what should happen? My guess is that since the good ole new operator allocates the memory we get an SEH memory access violation exception. Given that this can occur in my...
7
1672
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. Firstly this is an extended stored procedure DLL, I've been able to debug it successfully by starting SQL server with the -c switch and when it is called via osql then it breaks into the debugger. Fine. I'm happy with that.... However the project...
29
15551
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" ---Start of test.aspx---- <%@ Page language="C#" AutoEventWireup="false" %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" > <HTML> <HEAD>
0
1607
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 that when I ran it and looked at memory usage (in Windows task manager) it looked as if there was a very slow leak. To isolate the issue:
1
3729
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 an alternative to the mentalis.org's IniReader, I submit the following files to the web news group DBs...: @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
3
1322
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 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...
3
1791
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 is to be loaded into the process of the C# application, i.e. I want to avoid expensive IPC
7
1626
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 of exe/dll should I develop in Visual C++ so that I can meet these requirements 1) No administrator rights are required
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
10313
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...
1
10080
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,...
1
7494
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6735
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5378
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?
1
4044
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3643
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.