I'm trying to run the Windows System Assessment Tool (winsat.exe) using the following code:
System.Diagnostics.Process WinSPro =
new System.Diagnostics.Process();
System.Diagnostics.ProcessStartInfo WinSSInfo =
new System.Diagnostics.ProcessStartInfo();
WinSSInfo.FileName = "cmd.exe";
WinSSInfo.Arguments = "/k winsat.exe";
WinSPro.StartInfo = WinSSInfo;
WinSPro.Start();
This code works if I only call cmd.exe, and even if I call regedit.exe it still works. However, when I try to call winsat.exe as a argument of cmd.exe, it fails. The command prompt shows this:
'winsat.exe' is not recognized as an internal or external command, operable program or batch file.
I tried several ways to call winsat.exe:
Call it directly by assigning "winsat.exe"
to ProcessStartInfo.FileName
. It fails with a Win32Exception
: The system cannot find the file specified
As above, using the full path - @"c:\windows\system32\winsat.exe"
. It fails with the same error.
Run the code as the System Administrator. It still fails.
Call winsat.exe as in the coded example. It failed as I explained earlier.
It's interesting that the command prompt launched from the code can only see .dll files in c:\windows\system32.
Does anyone have any idea why winsat.exe cannot be launched through System.Diagnostics.Process
? Are there any limitations which I've misunderstood?
Thanks,
Rex
Winsat.exe is located in the C:\Windows\System32 folder. The file size on Windows 10/8/7/XP is 3,367,424 bytes. Winsat.exe is a Windows core system file. It is a Microsoft signed file. The program has no visible window.
winsat.exe is redirected using Windows-on Windows 64-bit redirection. What's happening is that your launch request (from a 32-bit process) is being redirected to %windir%\SysWOW64\winsat.exe. Since there's no 32-bit version of this particular executable on 64-bit installs, the launch fails.
The process known as Windows System Assessment Tool or Windows Sistem Deðerlendirme Aracý belongs to software Microsoft Windows Operating System or Microsoft Windows Ýþletim Sistemi by Microsoft (www.microsoft.com). Description: The original winsat.exe is an important part of Windows and rarely causes problems.
Usually, the error is a onetime thing and isn’t a serious error. Press Windows key once. Type cmd in the Start Search. Right click the Command Prompt from the search results and select run as administrator. Type winsat formal and press Enter.
winsat.exe
is redirected using Windows-on Windows 64-bit redirection. What's happening is that your launch request (from a 32-bit process) is being redirected to %windir%\SysWOW64\winsat.exe
. Since there's no 32-bit version of this particular executable on 64-bit installs, the launch fails. To bypass this process and allow your 32-bit process to access the native (64-bit) path, you can reference %windir%\sysnative
instead:
Process WinSPro = new Process();
ProcessStartInfo WinSSInfo = new ProcessStartInfo();
WinSSInfo.FileName = @"c:\windows\sysnative\winsat.exe";
WinSPro.StartInfo = WinSSInfo;
WinSPro.Start();
Alternatively, if you build your program as x64, you can leave the path as c:\windows\system32
.
Note that it's best to use Environment.GetFolderPath
to get the path to the windows directory, just in case the OS is installed in a non-standard location:
WinSSInfo.FileName = Path.Combine(
Environment.GetFolderPath(Environment.SpecialFolder.Windows),
@"sysnative\winsat.exe");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With