1.

Solve : How do I run an .exe from CScript without creating a separate window??

Answer» <html><body><p>All the examples I have found are like this:<br/><br/>Dim oShell<br/>Set oShell = WScript.CreateObject ("WSCript.shell")<br/>oShell.run "cmd /<a href="https://interviewquestions.tuteehub.com/tag/k-236601" style="font-weight:bold;" target="_blank" title="Click to know more about K">K</a> CD C:\ &amp; 7z a E:\ZipOut1 C:\TempBase"<br/>Set oShell = Nothing<br/><br/>I would like to run several 7z commands in succession using <a href="https://interviewquestions.tuteehub.com/tag/cscript" style="font-weight:bold;" target="_blank" title="Click to know more about CSCRIPT">CSCRIPT</a>, but without creating a separate window for each one, and ideally without creating any new windows at all.<br/> Code: <a>[Select]</a><br/>wscript.echo "Running 3 7zip operations"<br/>wscript.echo<br/>Run "7z a s:\ZipOut1 s:\Test-777\*"<br/>Run "7z a s:\ZipOut2 s:\Test-777\*"<br/>Run "7z a s:\ZipOut3 s:\Test-777\*"<br/>wscript.echo<br/>wscript.echo "Completed 7z operations"<br/>wscript.echo<br/>wscript.echo "Files produced:"<br/>wscript.echo<br/>Run "cmd /c dir s:\Zipout*"<br/>wscript.echo<br/>wscript.echo "Done"<br/><br/>' Runs an external program and pipes its output to<br/>' the StdOut and StdErr streams of the current script.<br/>' Returns the exit code of the external program.<br/>Function Run (ByVal cmd)<br/> Dim sh: Set sh = CreateObject("WScript.Shell")<br/> Dim wsx: Set wsx = Sh.Exec(cmd)<br/> Do<br/>    Dim Status: Status = wsx.Status<br/>    WScript.StdOut.Write wsx.StdOut.ReadAll()<br/>    WScript.StdErr.Write wsx.StdErr.ReadAll()<br/>    If Status &lt;&gt; 0 Then Exit Do<br/>    WScript.Sleep 10<br/>    Loop<br/> Run = wsx.ExitCode<br/>End Function<br/><br/><br/> Code: <a>[Select]</a>Running 3 7zip operations<br/><br/><br/>7-Zip 4.65  Copyright (c) 1999-2009 Igor Pavlov  2009-02-03<br/><br/>Scanning<br/><br/>Updating archive s:\ZipOut1.7z<br/><br/>Compressing  Readme.txt<br/>Compressing  Windows Active Boot Disk.vmx<br/>Compressing  Windows Active Boot Disk.vmxf<br/><br/>Everything is Ok<br/><br/>7-Zip 4.65  Copyright (c) 1999-2009 Igor Pavlov  2009-02-03<br/><br/>Scanning<br/><br/>Updating archive s:\ZipOut2.7z<br/><br/>Compressing  Readme.txt<br/>Compressing  Windows Active Boot Disk.vmx<br/>Compressing  Windows Active Boot Disk.vmxf<br/><br/>Everything is Ok<br/><br/>7-Zip 4.65  Copyright (c) 1999-2009 Igor Pavlov  2009-02-03<br/><br/>Scanning<br/><br/>Updating archive s:\ZipOut3.7z<br/><br/>Compressing  Readme.txt<br/>Compressing  Windows Active Boot Disk.vmx<br/>Compressing  Windows Active Boot Disk.vmxf<br/><br/>Everything is Ok<br/><br/>Completed 7z operations<br/><br/>Files produced:<br/><br/> Volume in <a href="https://interviewquestions.tuteehub.com/tag/drive-959713" style="font-weight:bold;" target="_blank" title="Click to know more about DRIVE">DRIVE</a> S is USB-1<br/> Volume Serial Number is 2C51-AA7F<br/><br/> Directory of s:\<br/><br/>24/10/2010  04:17 PM             1,561 ZipOut1.7z<br/>24/10/2010  04:17 PM             1,561 ZipOut2.7z<br/>24/10/2010  04:17 PM             1,561 ZipOut3.7z<br/>               3 File(s)          4,683 bytes<br/>               0 Dir(s)  156,771,778,560 bytes free<br/><br/>DoneI have tidied things up a bit; also I show how to use <a href="https://interviewquestions.tuteehub.com/tag/quotes-1175233" style="font-weight:bold;" target="_blank" title="Click to know more about QUOTES">QUOTES</a> around paths/filenames with <a href="https://interviewquestions.tuteehub.com/tag/spaces-1219927" style="font-weight:bold;" target="_blank" title="Click to know more about SPACES">SPACES</a>. Inside strings, quotes need "escaping". That is,  to get one quote mark inside a VBScript string, you need two in the code that produces the string.<br/><br/> Code: <a>[Select]</a>wscript.echo "Running 3 7zip operations"<br/>Run "7z a ""S:\Test\Batch\After 16-10-2010\vbs-samewindow\7zip Archives\ZipOut1.7z"" ""S:\Test\Batch\After 16-10-2010\vbs-samewindow\Folder with spaces\*"""<br/>Run "7z a ""S:\Test\Batch\After 16-10-2010\vbs-samewindow\7zip Archives\ZipOut2.7z"" ""S:\Test\Batch\After 16-10-2010\vbs-samewindow\Folder with spaces\*"""<br/>Run "7z a ""S:\Test\Batch\After 16-10-2010\vbs-samewindow\7zip Archives\ZipOut3.7z"" ""S:\Test\Batch\After 16-10-2010\vbs-samewindow\Folder with spaces\*"""<br/>wscript.echo "Done"<br/><br/>Function Run (ByVal cmd)<br/> Set sh = CreateObject("WScript.Shell")<br/> Set wsx = Sh.Exec(cmd)<br/> Do<br/>    Status = wsx.Status<br/>    WScript.StdOut.Write wsx.StdOut.ReadAll()<br/>    WScript.StdErr.Write wsx.StdErr.ReadAll()<br/>    If Status &lt;&gt; 0 Then Exit Do<br/>    WScript.Sleep 10<br/> Loop<br/> Run = wsx.ExitCode<br/>End Function<br/></p></body></html>


Discussion

No Comment Found