Multiple command-line commands using vbscript

Set oShell = CreateObject("WScript.Shell")
oShell.Run "cmd /c c:"

This line runs fine. Now I need to enter the text.

For instance: c:\users> "abcd"

How can I do this in the already open cmd tooltip.

+4
source share
1 answer

After each command, you must add & and change cmd / c to cmd / k

  • First command: CD / D c: \
  • Second Team: Dir
  • Third command: ping 127.0.0.1

Try it like this:

Set oShell = CreateObject("WScript.Shell")
Command = "cmd /K cd /d c:\ & Dir & ping 127.0.0.1"
oShell.Run Command,1,True
+6
source

All Articles