Download and execute a file hosted on a remote server?
up vote
0
down vote
favorite
Is it possible to download and execute a file hosted on a remote server using a .vbs script? My below attempt doesn't seem to work.
Dim objShell
Set objShell = WScript.CreateObject( "WScript.Shell" )
objShell.Run("""\12.345.67.789filename.exe""")
Set objShell = Nothing
windows windows-10 remote vbscript
add a comment |
up vote
0
down vote
favorite
Is it possible to download and execute a file hosted on a remote server using a .vbs script? My below attempt doesn't seem to work.
Dim objShell
Set objShell = WScript.CreateObject( "WScript.Shell" )
objShell.Run("""\12.345.67.789filename.exe""")
Set objShell = Nothing
windows windows-10 remote vbscript
You say you’re downloading the file, but, as far as I can see, you aren’t — you’re just trying to execute it from its remote location.
– G-Man
May 17 at 2:43
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
Is it possible to download and execute a file hosted on a remote server using a .vbs script? My below attempt doesn't seem to work.
Dim objShell
Set objShell = WScript.CreateObject( "WScript.Shell" )
objShell.Run("""\12.345.67.789filename.exe""")
Set objShell = Nothing
windows windows-10 remote vbscript
Is it possible to download and execute a file hosted on a remote server using a .vbs script? My below attempt doesn't seem to work.
Dim objShell
Set objShell = WScript.CreateObject( "WScript.Shell" )
objShell.Run("""\12.345.67.789filename.exe""")
Set objShell = Nothing
windows windows-10 remote vbscript
windows windows-10 remote vbscript
asked May 16 at 19:38
user905798
1
1
You say you’re downloading the file, but, as far as I can see, you aren’t — you’re just trying to execute it from its remote location.
– G-Man
May 17 at 2:43
add a comment |
You say you’re downloading the file, but, as far as I can see, you aren’t — you’re just trying to execute it from its remote location.
– G-Man
May 17 at 2:43
You say you’re downloading the file, but, as far as I can see, you aren’t — you’re just trying to execute it from its remote location.
– G-Man
May 17 at 2:43
You say you’re downloading the file, but, as far as I can see, you aren’t — you’re just trying to execute it from its remote location.
– G-Man
May 17 at 2:43
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
The following will get you what you want. Be sure to set the local file name (sLocalFile) to a path that your user has rights to write to or it will fail. Further, most antivirus apps will treat this as malware.
' variables
Dim xHttp, oStream, oShell, sRemoteURI, sLocalFile
' constants
Const klBinary = 1
Const klOverwrite = 2
' defined values
sRemoteURI = "https://example.com/filename.exe"
sLocalFile = """%appdata%filename.exe"""
' create the web request
Set xHttp = CreateObject("Microsoft.XMLHTTP")
xHttp.Open "GET", sRemoteURI, False
xHttp.Send
' save the file locally
Set oStream = CreateObject("Adodb.Stream")
oStream.Type = klBinary
oStream.Open
oStream.Write xHttp.responseBody
oStream.SaveToFile sLocalFile, klOverwrite
Set oStream = Nothing
Set xHttp = Nothing
' run the file
Set oShell = WScript.CreateObject("WScript.Shell")
oShell.Run(sLocalFile)
Set oShell = Nothing
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
The following will get you what you want. Be sure to set the local file name (sLocalFile) to a path that your user has rights to write to or it will fail. Further, most antivirus apps will treat this as malware.
' variables
Dim xHttp, oStream, oShell, sRemoteURI, sLocalFile
' constants
Const klBinary = 1
Const klOverwrite = 2
' defined values
sRemoteURI = "https://example.com/filename.exe"
sLocalFile = """%appdata%filename.exe"""
' create the web request
Set xHttp = CreateObject("Microsoft.XMLHTTP")
xHttp.Open "GET", sRemoteURI, False
xHttp.Send
' save the file locally
Set oStream = CreateObject("Adodb.Stream")
oStream.Type = klBinary
oStream.Open
oStream.Write xHttp.responseBody
oStream.SaveToFile sLocalFile, klOverwrite
Set oStream = Nothing
Set xHttp = Nothing
' run the file
Set oShell = WScript.CreateObject("WScript.Shell")
oShell.Run(sLocalFile)
Set oShell = Nothing
add a comment |
up vote
0
down vote
The following will get you what you want. Be sure to set the local file name (sLocalFile) to a path that your user has rights to write to or it will fail. Further, most antivirus apps will treat this as malware.
' variables
Dim xHttp, oStream, oShell, sRemoteURI, sLocalFile
' constants
Const klBinary = 1
Const klOverwrite = 2
' defined values
sRemoteURI = "https://example.com/filename.exe"
sLocalFile = """%appdata%filename.exe"""
' create the web request
Set xHttp = CreateObject("Microsoft.XMLHTTP")
xHttp.Open "GET", sRemoteURI, False
xHttp.Send
' save the file locally
Set oStream = CreateObject("Adodb.Stream")
oStream.Type = klBinary
oStream.Open
oStream.Write xHttp.responseBody
oStream.SaveToFile sLocalFile, klOverwrite
Set oStream = Nothing
Set xHttp = Nothing
' run the file
Set oShell = WScript.CreateObject("WScript.Shell")
oShell.Run(sLocalFile)
Set oShell = Nothing
add a comment |
up vote
0
down vote
up vote
0
down vote
The following will get you what you want. Be sure to set the local file name (sLocalFile) to a path that your user has rights to write to or it will fail. Further, most antivirus apps will treat this as malware.
' variables
Dim xHttp, oStream, oShell, sRemoteURI, sLocalFile
' constants
Const klBinary = 1
Const klOverwrite = 2
' defined values
sRemoteURI = "https://example.com/filename.exe"
sLocalFile = """%appdata%filename.exe"""
' create the web request
Set xHttp = CreateObject("Microsoft.XMLHTTP")
xHttp.Open "GET", sRemoteURI, False
xHttp.Send
' save the file locally
Set oStream = CreateObject("Adodb.Stream")
oStream.Type = klBinary
oStream.Open
oStream.Write xHttp.responseBody
oStream.SaveToFile sLocalFile, klOverwrite
Set oStream = Nothing
Set xHttp = Nothing
' run the file
Set oShell = WScript.CreateObject("WScript.Shell")
oShell.Run(sLocalFile)
Set oShell = Nothing
The following will get you what you want. Be sure to set the local file name (sLocalFile) to a path that your user has rights to write to or it will fail. Further, most antivirus apps will treat this as malware.
' variables
Dim xHttp, oStream, oShell, sRemoteURI, sLocalFile
' constants
Const klBinary = 1
Const klOverwrite = 2
' defined values
sRemoteURI = "https://example.com/filename.exe"
sLocalFile = """%appdata%filename.exe"""
' create the web request
Set xHttp = CreateObject("Microsoft.XMLHTTP")
xHttp.Open "GET", sRemoteURI, False
xHttp.Send
' save the file locally
Set oStream = CreateObject("Adodb.Stream")
oStream.Type = klBinary
oStream.Open
oStream.Write xHttp.responseBody
oStream.SaveToFile sLocalFile, klOverwrite
Set oStream = Nothing
Set xHttp = Nothing
' run the file
Set oShell = WScript.CreateObject("WScript.Shell")
oShell.Run(sLocalFile)
Set oShell = Nothing
answered Nov 21 at 8:32
shawn
865
865
add a comment |
add a comment |
Thanks for contributing an answer to Super User!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1323328%2fdownload-and-execute-a-file-hosted-on-a-remote-server%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
You say you’re downloading the file, but, as far as I can see, you aren’t — you’re just trying to execute it from its remote location.
– G-Man
May 17 at 2:43