0

I have a cmd file which I need to execute through vb scripting. The cmd file is not in C drive but in E drive.Do I need to first change the drive and then execute the command??

My script is as such

Dim objShell
Set objShell = WScript.CreateObject ("WScript.shell")
objShell.Run "E:\folder\abc.cmd"
Set objShell = Nothing

It just opens a powershell window and closes.

Any help would be greatly appreciated.Can someone please let me know if i am missing something.

Kaustav Basu
  • 33
  • 1
  • 1
  • 8
  • Have you tried anything yet? – Pankaj Jaju Jun 17 '16 at 15:21
  • Dim oShell Set oShell = WScript.CreateObject ("WScript.Shell") oShell.run "cmd.exe E:\somefolder\abc.cmd" Set oShell = Nothing'. Was trying something like this but it was not throwing any success or error message, so can't understand whether it's working – Kaustav Basu Jun 17 '16 at 15:37
  • 1
    You forgot the `/c` switch. – Cody Gray Jun 17 '16 at 16:37
  • @KaustavBasu. [Check out this answer](http://stackoverflow.com/questions/7526598/how-to-keep-the-vb-script-command-window-open-during-execution) for pausing the cmd window after your command is ran so you can see the output (otherwise it will just flash open, execute, and close before you can see what happened). – JNevill Jun 17 '16 at 16:50
  • @JNevill,I have tried something like this objShell.Run "E:\folder\abc.cmd /c SyncToyCmd.exe -R", 1, True Its still not working.Can you please help – Kaustav Basu Jun 20 '16 at 00:05

0 Answers0