Scenario:
Currently, there is a .lnk file which when executed does the following:
(from Property -> target)
%windir%\system32\cmd.exe /k set a=something&set
b=something2&c:\path\setsenvironment.cmd
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.
Problem:
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.
Thanks.