471,347 Members | 1,741 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

Running process from C#

Currently, there is a .lnk file which when executed does the following:

(from Property -> target)
%windir%\system32\cmd.exe /k set a=something&set
Note: the last parameter (C:\path\setsenvironment.cmd).
Executes and waits at the command prompt where the user types a .cmd
file name to execute and complete the whole process.
Eg: Execute
and this takes care of the rest of the processing.
How can I do this from C# program? I am required to automate this whole

process using Process. I know how run executables etc using process but

here I am not able to figure this one out.
This is what I tried to do with my existing code:
1. Tried to set environment variables using -
StartInfo.EnvironmentVariables.Add(key, value). EnvironmentVariables
being the ones from the lnk file.
2. WorkingDirectory as where the C:\Path is
Upon starting the process here is what I get:
Exception Details: System.ComponentModel.Win32Exception: The system
cannot find the file specified.

Dec 2 '05 #1
1 1693
See my reply for "Convert DOS execution to C# code".
I tested, it should work.
Tell me if it does not.

Dec 2 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Michael Schmitt | last post: by
3 posts views Thread by Billg_sd | last post: by
4 posts views Thread by sneffe | last post: by
4 posts views Thread by commander_coder | last post: by

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.