jiangok Posted June 15, 2009 Posted June 15, 2009 Hi, I try to call ServerManagerCmd.exe in C#. Below is my code: ProcessStartInfo startInfo = new ProcessStartInfo("ServerManagerCmd.exe", ""); Process process = Process.Start(startInfo); However, running this code always throws error "System.ComponentModel.Win32Exception: The system cannot find the file specified". I have verified ServerManagerCmd.exe is in c:\windows\system32 and I can run it in a command window without specifying the full path. Also there is no problem to run some other exe files in the same directory through the C# code, for example, wevtutil.exe. I also called ServerManagerLauncher.exe in C#. It has the same problem as ServerManagerCmd.exe. Why I cannot call any ServerManager*.exe in C# code? Thanks a lot for your help. Thanks Leon Quote
patricknl Posted June 4, 2010 Posted June 4, 2010 Late reply, quick note to others baffled searching for an answer. The system cannot find the file specified. I have verified ServerManagerCmd.exe is in c:\windows\system32 and I can run it in a command window Just ran into the same behaviour. Took me a while to figure out what was happening, thinking this had something to do along the line of starting the process without elevated rights, running the executable from a less-trusted file share or anything like that. The answer was less obvious than expected: You are running your code as a 32 bit application in a 64 bit Windows Server environment. The operating system uses the %SystemRoot%\system32 directory for its 64 bit executables. When executing 32 bit applications, WOW64 (Windows on Windows) redirects requests for DLLs from that directory to %SystemRoot%\sysWOW64. The process you're spawning should search for its files in a different location. A couple of suggestions when you can't find system DLLs you know are there: Solution 1. Build your program 64 bit. Solution 2. @"%WINDIR%\Sysnative\ServerManagerCmd.exe" Solution 3, @"%WINDIR%\SysWow64\ServerManagerCmd.exe" Solution 4. Start %windir%\SysWoW64\cmd.exe; set PATH=%systemroot%\SysWOW64;%PATH%; Regards, Patrick de Kleijn Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.