1

Alright, I've figured out my issue. I am using some software to remotely start programs on local computers. In doing so, I send a path across the network of a program that I want that machine to start. It uses Process.Start and stores the executing path. I then, later, resend that path and tell it close the Process that was associated with this path.

Process newProcess = Process.Start(startPath);
_runningProcesses.Add(new MCProcess(startPath, new Process);

Sometimes, I will use this to call a shortcut, which I use because I want to pass some command link arguments along with.

I've used this to call .exe and .lnk (shortcut extension) and it runs the programs just fine.

However, when passing in the path to a shortcut, the process that it returns is null! Therefor, when I send the path back to close the program, the process is null and it can't close the program.

Any solutions?

4

2 回答 2

3

You don't need shortcut to pass arguments to the program, just do following:

Process process = new Process();
process.StartInfo.FileName = "\"C:\\my.exe\"";
process.StartInfo.Arguments = "arg1 arg2 arg3";
//...
process.Start();

In command line it would look like C:\my.exe arg1 arg2 arg3

于 2012-12-21T19:36:25.230 回答
0

just take the target of the shortcut if its necessary to use the shortcut. Get target of shortcut folder

于 2012-12-21T19:35:42.593 回答