我通过堆栈溢出搜索发现了这一点,但是没有人提供有效的解决方案.我正在编写一个简单的程序,其第一部分是使用一些参数启动sysprep.exe.由于某种原因,运行代码时sysprep无法启动.出现错误,找不到文件.例如使用记事本下面的代码将不会出现任何问题.如果尝试打开sysprep,则不会.
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"); } }推荐答案
在64位Windows上,这实际上是一个重定向问题. 根据此讨论, System32调用将重定向到SysWOW64文件夹. 而且由于C:\Windows\SysWOW64\Sysprep\sysprep.exe不存在,您会收到错误消息.
It is actually a redirection problem on 64 bit Windows. According to this discussion, the System32 calls are redirected to the SysWOW64 folder. And since C:\Windows\SysWOW64\Sysprep\sysprep.exe does not exist, you get the error.
这就是您想要的:
Process p = Process.Start(@"C:\Windows\sysnative\Sysprep\sysprep.exe");只需使用sysnative即可.
更多推荐
在C#中启动SYSPREP
发布评论