How to create a file without a command prompt window
I am using the WinRAR SFX module to create an installation and use its pre-configuration option to run some pre-tests.
Since wscript can only accept the vbs file and not the script itself, I first run "cmd / c echo {... script code ...}> setup.vbs" and then run "setup wscript.vbs". Running the first cmd command opens a short command window, and I would really like to avoid that. I thought about using RunDll32 to write this data, but couldn't find a suitable API to use.
Can anyone think of a way to work around it and create a small file with little VBScript text without opening a command prompt window?
Many thanks,
splintor
source to share
Is the script code already in the file? If yes,
You can use the TYPE command to send the script to a file:
TYPE [script_file] > setup.vbs
or COPY script file:
COPY [script_file] setup.vbs
If the script code is in the body of yours cmd
, you can use the command START
to run cmd
without window ( /b
):
START /B cmd /c echo {...script code...} > setup.vbs
source to share
Instead of being used cmd /c echo {...script code...} > setup.vbs
as a preconfiguration step, perhaps you can package a VBscript with your setup that runs your pre-tests and builds setup.vbs
and then calls setup.vbs
for you. You have to put this in the WinRAR install script.
You can call other VBScript from VBScript like this:
Set WSHShell = CreateObject("WScript.Shell")
WSHShell.Run "wscript d:\setup.vbs, ,True
See this MSDN link for the Run command syntax.
source to share