在C#中启动SYSPREP [英] Launch SYSPREP in C#

查看:89
本文介绍了在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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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