-2

I am working on shell script/ .vbs extension file, and I want to run a batch file hiddenly or in background from shell script. I am mentioning my code but its not executing a batch file. I have saved my file with a name test.vbs.

Set WshShell = CreateObject()
WshShell.Run chr(34) & "%USERPROFILE%\AppData\Local\RE.bat" & Chr(34), 0
Set WshShell = Nothing

Thanks in advance.

oguz ismail
  • 1
  • 16
  • 47
  • 69

2 Answers2

2

when you write CreateObject(), you have to mention in those circle brackets. Your code looks fine just add WScript.shell in circle brackets like this.

Set WshShell = CreateObject("WScript.shell")
0

You need CreateObject("WScript.Shell"), not CreateObject():

Set WshShell = CreateObject("WScript.Shell")
WshShell.Run Chr(34) & "%USERPROFILE%\AppData\Local\RE.bat" & Chr(34), 0

Otherwise VBScript wouldn't know what you want to create! So it can't know you want the shell object that has the Run method...

CherryDT
  • 25,571
  • 5
  • 49
  • 74