Domanda

Voglio eseguire il file VBScript utilizzando cscript.exe. Ho cercato molto ma non ho trovato in alcun modo mentre posso eseguire il mio script usando cmd con cscript.exe

Questo è il mio codice

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

Qualsiasi idea di come posso usare cscript.exe

È stato utile?

Soluzione

È necessario impostare la proprietà FileName sull'eseguibile che si desidera eseguire. Nel tuo caso sarebbe cscript.exe e non testing:

p.StartInfo.Arguments = @"""C:\Program Files\VDIWorkLoad\WorkLoadFile\open test.vbs""";
p.StartInfo.FileName = @"C:\Windows\System32\cscript.exe";
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top