Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
528 views
in Technique[技术] by (71.8m points)

vb.net - Error using Process.Start()

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:WindowsSystem32sysprep"
    P.StartInfo.FileName = "sysprep.exe"
    P.Start()
End Sub
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I think you just stumbled uppon the http://msdn.microsoft.com/en-us/library/aa384187.aspx

The %windir%System32 directory is reserved for 64-bit applications. Most DLL file names were not >changed when 64-bit versions of the DLLs were created, so 32-bit versions of the DLLs are stored in a >different directory. WOW64 hides this difference by using a file system redirector.

What happens is that your launch request (from a 32-bit process) is being redirected to %windir%SysWOW64sysprepsysprep.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%SysNativesysprepsysprep.exe instead of %windir%System32sysprepsysprep.exe which is what you have.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...