I have found this via stack-overflow search but no one has given a solution that works. I am writing a simple program and the first part of it is to launch sysprep.exe with some arguments. For some reason sysprep does not launch when code is run. It gives an error that file cannot be found. For e.g. by using the code below Notepad will open with no issues. If I try and open sysprep it will not.
Process.Start(@"C:\Windows\System32\notepad.exe"); -- opens with no issue
Process.Start(@"C:\Windows\System32\sysprep\sysprep.exe"); -- does not open
Any help would be appreciated.
{
public MainWindow()
{
InitializeComponent();
}
private void RadioButton_Checked(object sender, RoutedEventArgs e)
{
if (radioButtonYes.IsChecked == true)
{
Process.Start(@"C:\Windows\System32\sysprep\sysprep.exe");
}
}
I see that another answer has worked for you, but I would like to include a different answer that will allow you to access files from System32 at any time. If you start with a public class to modify the kernel momentarily you should be able to access anything you need so long as you have the right permissions.
After this the way that i wrote out my call to sysprep was as follows
when doing something like this you want to make sure that if the process will restart your pc to NOT use the "WaitForExit()" method. Hope this helps anyone else looking for this answer.
I think this is a permission problem, you can try run as admin
It is actually a redirection problem on 64 bit Windows. According to this discussion, the
System32
calls are redirected to theSysWOW64
folder. And sinceC:\Windows\SysWOW64\Sysprep\sysprep.exe
does not exist, you get the error.This is what you want:
Simply use
sysnative
instead.