run vb script using script.exe

会有一股神秘感。 提交于 2020-01-14 05:14:11

问题


I want to run vbscript file using cscript.exe. i searched a lot but did'nt found any way while i can run my script using cmd with cscript.exe

this is my code

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.");
            }

any idea how i can use cscript.exe


回答1:


You should set the FileName property to the executable you want to run. In your case that would be cscript.exe and not testing:

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


来源:https://stackoverflow.com/questions/8850834/run-vb-script-using-script-exe

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!