I have vbs script and that creates folder, make archive and copy to that folder, upload to ftp and so on. I want it to write status to cmd after each step of execution( after creating folder, zip…)
The following opens cmd.exe and writes there “creates folder”. That’s exactly what I want.
Dim objShell, strCmd
strCmd = "%comspec% /k echo creates folder"
Set objShell = CreateObject("Wscript.Shell")
objShell.Run strCmd, 1, True
But, how I can write to the same cmd window that just opened? If I use this
strCmd = "%comspec% /k echo starting zip"
objShell.Run strCmd, 1, True
it opens new cmd window, but I want to write “starting zip” to previously opened cmd.
How I achieve this?
To print to the command prompt use wscript.echo.
I want to point out that the behavior of .echo is effected by how the script is loaded. For instance, if I run it from command prompt, like this:
test.vbs, then the echo lines show up as pop-ups due to running wscript by default. However, if instead I load the file like this:cscript text.vbsall output goes to console as expected.