I am trying to run sysprep from a vb.net application, and even though the path and file name are confirmed accurate, it is returning that it can not find the file. I've tried using process.start, declaring as a new process, declaring the path separate from the file name. Here is the code as I would like it to be written, maybe someone could try it out and see if they come up with a solution?
Private Sub btnsysp_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnsysp.Click
Dim P As New System.Diagnostics.Process()
P.StartInfo.UseShellExecute = True
P.StartInfo.WorkingDirectory = "C:\Windows\System32\sysprep\"
P.StartInfo.FileName = "sysprep.exe"
P.Start()
End Sub
I think you just stumbled uppon the http://msdn.microsoft.com/en-us/library/aa384187.aspx
What happens is that your launch request (from a 32-bit process) is being redirected to
%windir%\SysWOW64\sysprep\sysprep.exe
. Since there's no 32-bit version of this particular executable on SysWOW64 the launch fails.The easiest way to bypass this problem is using reference to
%windir%\SysNative\sysprep\sysprep.exe
instead of%windir%\System32\sysprep\sysprep.exe
which is what you have.