在C#中启动SYSPREP

编程入门 行业动态 更新时间:2024-10-09 20:23:46
本文介绍了在C#中启动SYSPREP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我通过堆栈溢出搜索发现了这一点,但是没有人提供有效的解决方案.我正在编写一个简单的程序,其第一部分是使用一些参数启动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

本文发布于:2023-11-27 12:44:46,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1638129.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:SYSPREP

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!