-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.

0

2 Answers 2

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")
Sign up to request clarification or add additional context in comments.

Comments

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...

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.