使用Process.Start()时出错 [英] Error using Process.Start()

查看:266
本文介绍了使用Process.Start()时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从vb.net应用程序运行sysprep,即使确认路径和文件名正确,它仍返回它找不到该文件的信息.我尝试使用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:\Windows\System32\sysprep\"
    P.StartInfo.FileName = "sysprep.exe"
    P.Start()
End Sub

推荐答案

我认为您偶然发现 http://msdn.microsoft.com/en-us/library/aa384187.aspx

%windir%\ System32目录保留用于64位应用程序.创建64位版本的DLL时,大多数DLL文件名均未更改,因此32位版本的DLL存储在不同目录中. WOW64通过使用文件系统重定向器隐藏了这种差异.

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.

会发生什么事,您的启动请求(来自32位进程)将被重定向到%windir%\SysWOW64\sysprep\sysprep.exe.由于SysWOW64上没有此特定可执行文件的32位版本,因此启动失败.

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.

绕过此问题的最简单方法是使用对%windir%\SysNative\sysprep\sysprep.exe的引用,而不是您所拥有的%windir%\System32\sysprep\sysprep.exe.

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.

这篇关于使用Process.Start()时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆