1

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?

4
  • WScript.echo "starting zip" ? Commented Oct 29, 2012 at 13:44
  • It's opens popup and I don't want any popup or GUI I want to write to the same black command prompt Commented Oct 29, 2012 at 13:51
  • As Daniel Cook says, make sure you use cscript Commented Oct 29, 2012 at 13:59
  • @AlexK, indeed if I use cscript it works. Thanks guys Commented Oct 29, 2012 at 14:27

1 Answer 1

2

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.vbs all output goes to console as expected.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.