【问题标题】:Getting execption whenever it runs from process.start每当从 process.start 运行时获取异常
【发布时间】:2016-02-05 11:13:31
【问题描述】:

所以我在 win 7 电脑上遇到了这个奇怪的问题。我有这个来自 .bat 文件的应用程序 runs this powershell script。 这是代码:

public void GetLastestEarthBackground()
{
    var directoryPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Scripts");
    var vbsFile = Path.Combine(directoryPath, Settings.VBSFileName);

    if (File.Exists(vbsFile))
    {
        var process = new Process
        {
            StartInfo =
            {
                WorkingDirectory = directoryPath,
                Verb = "runas",
                UseShellExecute = true,
                FileName = "run.bat", //Settings.VBSFileName,
                Arguments = "//B //Nologo"
            }
        };
        process.Start();
        process.WaitForExit();
    }
}

当我从我的应用程序运行它时,我会在命令行中看到:

但是如果我双击批处理文件,我会得到这个结果:

有什么想法吗?

【问题讨论】:

    标签: c# powershell command-line


    【解决方案1】:

    这似乎是用户权限的问题,运行脚本的程序可能与您的用户没有相同的权限。

    【讨论】:

    • 好的,我一直在尝试将应用程序设置为以管理员身份运行,但我仍然遇到同样的问题。我添加了一个app.manifest,我尝试安装它并使用“以管理员身份运行”选项。到目前为止没有任何帮助。
    猜你喜欢
    • 1970-01-01
    • 2013-09-20
    • 1970-01-01
    • 2017-07-01
    • 2012-04-28
    • 2012-08-07
    • 2019-02-22
    • 1970-01-01
    • 2018-08-20
    相关资源
    最近更新 更多