Your code is totally wrong. There is absolutely no need for cmd.exe
to be involved in this operation, nor is there a need for call /c
(and there's absolutely no need to require elevation as your answer suggests).
if FileExists(localFileName) {
try
{
System.Diagnostics.Process.Start(localFileName);
catch
}
/*
Handle failure to start process (Win32Exception)
No need to handle FileNotFoundException, because
you can do that in the else below
*/
};
}
else
{
// Handle missing file
}
cmd.exe
is not needed, as it opens a new instance of the Windows command processor (AKA a command prompt), and call /c
is only needed when CALL
ing another batch file from within a batch file. There is certainly no need to elevate the process as your answer suggests.