473,792 Members | 2,807 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 1322
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
6332
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
15553
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>
1
2525
by: Peter Oliphant | last post by:
I have a C++ Console application being written using VS C++.NET 2005 Express. It never crashes and seems to be working just fine. However, when I close the application via the Console 'X' exit button in upper right corner of its dialog box I get the following exit code: "The program ' MyApplication.exe: Managed' has exited with code -1073741510 (0xc000013a)." If I close it via the 'X' in the application form it exits with exit code 0:
0
1608
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
1245
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
1792
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
9670
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
10159
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,...
0
10000
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7538
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
5436
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
5560
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4111
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
3719
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2917
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.