【问题标题】:run vb script using script.exe使用 script.exe 运行 vb 脚本
【发布时间】:2026-02-14 04:00:01
【问题描述】:

我想使用 cscript.exe 运行 vbscript 文件。 我搜索了很多,但没有找到任何方法,而我可以使用 cmd 和 cscript.exe 运行我的脚本

这是我的代码

Process p = new Process();
            p.StartInfo.Arguments = @"C:\\Program Files\\VDIWorkLoad\\WorkLoadFile\\open test.vbs";
            p.StartInfo.FileName = "testing";
            p.StartInfo.UseShellExecute = false;
            try
            {
                p.Start();
                p.WaitForExit();
                Console.WriteLine("Done.");
            }

知道如何使用 cscript.exe

【问题讨论】:

    标签: c# .net process.start wsh


    【解决方案1】:

    您应该将 FileName 属性设置为要运行的可执行文件。在您的情况下,这将是 cscript.exe 而不是 testing

    p.StartInfo.Arguments = @"""C:\Program Files\VDIWorkLoad\WorkLoadFile\open test.vbs""";
    p.StartInfo.FileName = @"C:\Windows\System32\cscript.exe";
    

    【讨论】:

    • 当我尝试使用 system.diagnostic.start(path); 运行我的脚本时,你能指导我吗?它工作正常,但是当尝试使用窗口服务执行时它没有任何想法?