Skip to content

Instantly share code, notes, and snippets.

@rcmdnk
Last active July 17, 2023 07:03
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save rcmdnk/7631748 to your computer and use it in GitHub Desktop.
Save rcmdnk/7631748 to your computer and use it in GitHub Desktop.
Program install script for Windows. Useful for programs which don't have installer. If the program has a zip file and zip includes folder, just download it and extract in Download folder. Otherwise, make new folder in Download folder, and put all necessary files. Then run install.vbs (download this script and save as "install.vbs", and double cl…
' Set basic objects
Set wssh = WScript.CreateObject("WScript.Shell")
Set fs = WScript.CreateObject("Scripting.FileSystemObject")
Set nw = WScript.CreateObject("WScript.Network")
Set sh = CreateObject("Shell.Application")
' Basic Values
progFiles = "C:\Program Files"
startMenu = wssh.SpecialFolders("AllUsersPrograms")
defRoot = "C:\Users\" & nw.UserName & "\Downloads"
' Pathes
sName = Wscript.ScriptName
pPath = ""
pName = ""
' Set Folder to install
Set objFolder = sh.BrowseForFolder(0, "Choose Program Folder to be installed.", 1, defRoot)
' Check Folder
If objFolder is Nothing then
WScript.Quit
Else
pPath = objFolder.Items.Item.Path
pName = objFolder.Items.Item.Name
End If
If Not fs.FolderExists(pPath) then
MsgBox pPath & " is not found!",,sName
WScript.Quit
End If
If fs.FolderExists(progFiles & "\" & pName) then
MsgBox pName & " is already installed in " & progFiles & ".",,sName
WScript.Quit
End If
If fs.FolderExists(startMenu & "\" & pName) then
MsgBox pName & " exists in " & startMenu & ", but not in " & progFiles & ", please check.",,sName
WScript.Quit
End If
' Copy Folder to progFiles
fs.CopyFolder pPath,progFiles & "\" & pName
' Make symbolic links to startMenu
Set objExec = wssh.Exec("cmd /C mklink /D """ & startMenu & "\" & pName & """ """ _
& progFiles & "\" & pName & """")
Do Until objExec.StdErr.AtEndOfStream
strLine = objExec.StdErr.ReadLine
MsgBox strLine
Loop
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment