I’m going to leave this in the PowerShell forum, admins feel free to move it.<\/p>\n
Advertisement
Im playing around with the idea of creating a script (or something) that would automate our laptop setups, something that will automatically install all our small programs like CutePDF and DWG Trueview. The main idea behind this is to save us some time when it comes to setting up a new laptop for a new user.<\/p>\n
I have written up (pen and paper) a rough draft of what I want it to do, but I’m so wet behind the ears when it comes to scripting that I make the Nile look tad dehydrated.<\/p>\n
So the question is this: Is it possible to write a script that will pull the installers from a network location and install the programs on a laptop automatically?<\/p>\n
Aside: Have you done this? How did you go about writing the script or whatever you used for it?<\/p>\n
Thanks in advance…<\/p>","upvoteCount":10,"answerCount":15,"datePublished":"2015-01-07T11:16:18.000Z","author":{"@type":"Person","name":"anton-thecat","url":"https://community.spiceworks.com/u/anton-thecat"},"acceptedAnswer":{"@type":"Answer","text":"
In this day in age definately go with some deployment software as suggested like PDQ Deploy… It’ll also help keeping things update. However, it is POSSIBLE to do it via scripting… WAAAY back in the day of 2000/XP, I wrote a fully scripted install of windows. After the installation, here’s some of the scripts I used if it helps. However, this was probably one of the first things I wrote in vbscript, so it may not be the best <\/p>\n
Runinst.vbs - Runs all scripts in a folder<\/strong><\/p>\n
' runinst.vbs: run commands in the given folder\n'\n' USAGE\n'\n' runinst.vbs FOLDER\n'\n' FOLDER Path of folder containing installations to run\n'\n' NOTES\n'\n' This script supports files with the extensions EXE,\n' MSI, BAT, CMD, JS, VBS, REG, and INF.\n'\n' If the folder doesn't exist, this script displays an error\n' message that times out in 10 seconds, since it's for use during\n' the Windows setup process and the folder doesn't always exist.\n'\n\nOption Explicit\n\nMain()\n\nSub Main()\n\n ' Check the command-line argument (which must be the path of\n ' a folder that contains installations to run); then, call\n ' LaunchInstallations to silently run each installation contained\n ' in the folder.\n '\n Dim intRC\n Dim objArguments\n Dim objFileSystem\n Dim objShell\n\n Set objArguments = WScript.Arguments\n Set objFilesystem = CreateObject( \"Scripting.FileSystemObject\" )\n Set objShell = CreateObject( \"WScript.Shell\" )\n\n If objArguments.Count > 0 Then\n If objFileSystem.FolderExists( objArguments(0) ) Then\n LaunchInstallations( objArguments(0) )\n Else\n\n ' The folder doesn't exist\n\n intRC = objShell.Popup( \"The folder \" & objArguments(0) & \" doesn't exist.\", 10, \"Folder Missing\", 0 )\n\n End If\n\n Else\n\n ' No folder was given on the command line\n\n WScript.Echo \"Usage: runinst.vbs FOLDER\"\n\n End If\n\nEnd Sub\n\nSub LaunchInstallations( strPath )\n\n ' Execute each installation file contained in strPath silently:\n '\n ' strPath Path of the folder containing installations\n '\n\n Dim objFileSystem\n Dim objShell\n\n Set objFilesystem = CreateObject( \"Scripting.FileSystemObject\" )\n Set objShell = CreateObject( \"WScript.Shell\" )\n\n ' Build a list of files in the given subfolder\n\n Dim intRC\n Dim objFolder\n Dim colFiles\n Dim objFile\n\n Set objFolder = objFileSystem.GetFolder( strPath )\n Set colFiles = objFolder.Files\n\n ' Launch each file in the list using the appropriate command\n\n For Each objFile in colFiles\n Select Case UCase( objFileSystem.GetExtensionName( objFile ))\n\n Case \"EXE\"\n intRC = objShell.Run( objFile, 1, True )\n\n case \"MSI\"\n\n Dim objWMIService\n Dim strProcessName\n\n ' Wait for any current MSI processes to finish\n\n strProcessName = \"msiexec.exe\"\n Set objWMIService = GetObject(\"winmgmts:\\\\.\\root\\cimv2\")\n\n Do While objWMIService.ExecQuery( \"Select Name from Win32_Process where Name='\" & strProcessName & \"'\").Count > 1\n WScript.Sleep 5000\n Loop\n\n intRC = objShell.Run( \"msiexec.exe /qb /i \" & objFile & \" ALLUSERS=2\", 1, True )\n\n Case \"BAT\"\n intRC = objShell.Run( \"cmd.exe /c \" & objFile, 1, True )\n\n Case \"CMD\"\n intRC = objShell.Run( \"cmd.exe /c \" & objFile, 1, True )\n\n Case \"JS\"\n intRC = objShell.Run( \"wscript.exe //e:jscript \" & objFile, 1, True )\n\n Case \"VBS\"\n intRC = objShell.Run( \"wscript.exe //e:vbscript \" & objFile, 1, True )\n\n Case \"REG\"\n intRC = objShell.Run( \"regedit.exe /s \" & objFile, 1, True )\n\n Case \"INF\"\n intRC = objShell.Run( \"rundll32.exe setupapi,InstallHinfSection DefaultInstall 132 \" & objFile, 1, True )\n\n End Select\n Next\n\nEnd Sub\n<\/code><\/pre>\n
<\/strong>00_SmartInsaller.vbs - Brains to control the installer based on a CSV<\/strong><\/p>\n
'==========================================================================\n' smartInstaller.vbs\n' AUTHOR: Sigkill\n' VERSION: 1.0\n'Rules:\n'Requires the Master Software list to be a CSV file\n'Case is Not Sensitive\n'Each Location Belongs in the Col 1 Starting in Row 3\n'Make Sure There are No BLANK Cells in Col 1\n'Make Sure There are No BLANK Cells in Row 1\n'Row 1 Contains the Name of the Install Script Beginning in Column 2\n'Row 2 Contains the Description of the Installer Script Beginning in Column 2\n'Mark Each Location with a \"Yes\" or \"No\" under Each Installer Or you can mark a special computer case in a room by\n' using * followed by -## for each special computer in that room. (Ex: *-01-03) This only installs on computers 01 and 03\n'If an Installer Cannot Be Silently Installed, Start the Installer Name with a \"*\" (Ex: *01_Installer.bat)\n'Any Installer Marked with a \"*\" Will Never Install, Even If It is Marked as \"Yes\"\n'Installer Names 00-09 are for Security Installers\n'Installer Names 10-19 are for Standard Application Installers\n'Installer Names 20-49 are for Additional Application Installers\n'Installer Names 50-79 are for Custom Application Installers\n'Installer Names 80-89 are for Custom Machine Installers, (Ex: CD Burning Software , or a wirless utility)\n'Installer Names 90-100 are for Cleanup of All Previous Installers and System Modifications\n'All Installer Files Contain All Specialized Directions in Comments, Including Ones that Need Manually Installed or Repackaged\n\n'==========================================================================\n' Force Explicit Variable Declaration\nOption Explicit\n\n' Call Main Execution Loop, and Quit with an Errorlevel of 0 When Done\nMain(): WScript.Quit(0)\n\n' **************************************************************************\n' Sub Main \n' **************************************************************************\nPublic Sub Main()\n\n\tOn Error Resume Next ' Start Main Error Handling\n\n\t' Create objects\n\tDim objFSO: Set objFSO = CreateObject(\"Scripting.FileSystemObject\")\n\tDim objShell: Set objShell = CreateObject( \"WScript.Shell\" )\n\tDim objNetwork: Set objNetwork = CreateObject(\"WScript.Network\")\n\n\t' Set Computer Name and Parse The Building Name using RSD Naming Convention\n\tDim strComp: strComp = UCase(objNetwork.ComputerName)\n\tDim strBuilding: strBuilding = Mid(strComp,1,3)\n\n\t' Set Path to Master Software List, Path to Scripts, and Local Install Directory\n\tDim strFile, strScripts, strLocalDir\n\tIf WScript.Arguments.Count = 3 Then\n\t\tstrFile = WScript.Arguments(0)\n\t\tstrScripts = WScript.Arguments(1)\n\t\tstrLocalDir = WScript.Arguments(2)\n\tElse\n\t\tstrFile = \"\\\\SERVER\\install\\MasterSoftwareList.csv\"\n\t\tstrScripts = \"\\\\SERVER\\install\\Apps\\Scripts\\\"\n\t\tstrLocalDir = objShell.ExpandEnvironmentStrings(\"%SystemRoot%\") & \"\\APPS\\RUNONCE\\\"\n\tEnd If\n\t\n\t' Ensure Path to Scripts Ends with \"\\\"\n\tIf Right(strScripts, 1) <> \"\\\" Then\n\t\tstrScripts = strScripts & \"\\\"\n\tEnd If\n\n\t' Ensure Local Install Directory Ends with \"\\\"\n\tIf Right(strLocalDir, 1) <> \"\\\" Then\n\t\tstrLocalDir = strLocalDir & \"\\\"\n\tEnd If\t\n\t\n\t' Ensure Master Software List and Path to Scripts Exist\n\tIf Not objFSO.FileExists(strFile) Then Wscript.Quit\n\tIf Not objFSO.FolderExists(strScripts) Then Wscript.Quit\n\t\n\t' Ensure Local Install Directory Exists or Create It\n\tDim arrLocalDir\n\tarrLocalDir = Split(strLocalDir, \"\\\")\n\tDim strTempPath: strTempPath = \"\"\n\tDim Folder, NewFolder\n\tFor each Folder in arrLocalDir\n\t\tIf Folder <> \"\" Then\n\t\t\tstrTempPath = strTempPath & Folder & \"\\\"\n\t\t\tIf Not objFSO.FolderExists(strTempPath) Then \n\t\t\t\tSet NewFolder = objFSO.CreateFolder(strTempPath)\n\t\t\tEnd If\n\t\tEnd If\n\tNext\n\t\n\t' Process Computer\n\tCall ProcessComputer(strComp, strFile, strScripts, strLocalDir)\n\n\t' Kill Objects\n\tSet objFSO = nothing\n\tSet objShell = nothing\n\tSet objNetwork = nothing\n\t\t\n\t' Kill Script\n\tCall ScriptSuicide()\n\t\n\tOn Error GoTo 0 ' End Main Error Handling\n\nEnd Sub\n\n' **************************************************************************\n' Sub ProcessComputer - Copies Installers to Local Machine according to Master Software List\n'\tstrComp = Computer Name\n'\tstrFile = Master Software List (CSV Delimited)\n'\tstrScripts = Network Path to Installer Scripts\n'\tstrLocalDir = Local Directory to Launch Scripts From\n' **************************************************************************\nPrivate Sub ProcessComputer(strComp, strFile, strScripts, strLocalDir)\n\n\t' Ignore All Errors\n\tOn Error Resume Next\n\n\t' Create Objects\n\tDim objFSO: Set objFSO = CreateObject(\"Scripting.FileSystemObject\")\n\tDim objShell: Set objShell = CreateObject(\"WScript.Shell\")\n\t\n\t' Open Log File For Appending\n\tConst ForAppending = 8\n\tDim logFile: Set logFile = objFSO.OpenTextFile(objShell.ExpandEnvironmentStrings(\"%SystemRoot%\\setuplog1.log\"), ForAppending, True)\n\tlogFile.WriteLine VBCRLF & VBCRLF & \"Copying Installers\"\n\tlogFile.WriteLine \"==========================================================\"\n\tlogFile.WriteLine \"Master Spreadsheet: \" & strFile\n\tlogFile.WriteLine \"Network Scripts: \" & strScripts\n\tlogFile.WriteLine \"Local Scripts: \" & strLocalDir\n\t\n\t' Define Variables\n\tConst ForReading = 1\n\t\n\t' Get Location (Portion After the Building)\n\tDim strLocation: strLocation = Mid(strComp,1,InstrRev(strComp,\"-\") - 1)\n\n\t' Open Master Software List\n\tDim objFile: Set objFile = objFSO.OpenTextFile(strFile, ForReading)\n\n\t' Declare Variables for Parsing Count and Matches\n\tDim i, strMatch\n\t\n\t' Search For Row to Parse, then Parse Install Options into arrInstall Array\n\tDim strLine, arrInstall\n\ti = 0\n\tDo Until objFile.AtEndOfStream\n\t\tstrLine = objFile.ReadLine\n\t\tIf strLocation = Left(strLine, InStr(strLine, \",\") - 1) Then\n\t\t\tarrInstall = Split(strLine, \",\")\n\t\t\tstrMatch = 1\n\t\t\tExit Do\n\t\tEnd If\n\tLoop\n\t\n\t' Close File\n\tobjFile.Close\n\n\t' Check For Invalid Location Matches\n\tIf strMatch = 0 Then \n\t\tExit Sub\n\tEnd If\n\n\t' Open Master Software List\n\tSet objFile = objFSO.OpenTextFile(strFile, ForReading)\n\t\n\t' Parse Installer Files into arrInstallers Array\n\tDim arrInstallers\n\tFor i = 1 to 1\n\t\tstrLine = objFile.ReadLine\n\t\tarrInstallers = Split(strLine, \",\")\n\tNext\n\t\n\t' Close File\n\tobjFile.Close\n\n\t' Find the Lowest Upper Bound of arrInstallers and arrInstall\n\tDim low\n\tIf UBound(arrInstallers) > UBound(arrInstall) Then\n\t\tlow = UBound(arrInstall)\n\tElseif UBound(arrInstallers) < UBound(arrInstall) Then\n\t\tlow = UBound(arrInstallers)\n\tElse\n\t\tlow = UBound(arrInstallers)\n\tEnd If\n\t' Trap Error If Either Array is Blank Because Col1 or Row 1 Are Blank In Excel File\n\tIf Err.Number <> 0 Then\n\t\t'Wscript.Echo Err.Number & vbCrLf & Err.Source & vbCrLf & Err.Description\n\t\tErr.Clear\n\t\t' Exit Sub\n\t\tExit Sub\n\tEnd If\t\n\t\n\t' Copy Specified Installers to Local Machine\n\tDim arrSpecial\n\tDim j\n\tFor i = 0 to low\n\t\tIf UCase(arrInstall(i)) = \"YES\" Then\n\t\t\tIf objFSO.FileExists(strScripts & arrInstallers(i)) Then\n\t\t\t\tlogFile.WriteLine \"Copying: \" & arrInstallers(i)\n\t\t\t\tobjFSO.CopyFile strScripts & arrInstallers(i), strLocalDir, True\n\t\t\tEnd If\n\t\tElseif Left(arrInstall(i)) = \"*\" Then\n\t\t\tarrSpecial = Split(arrInstall(i), \"-\")\n\t\t\tFor j = 1 to UBound(arrSpecial)\n\t\t\t\tIf strComp = strLocation & \"-\" & arrSpecial(j) Then\n\t\t\t\t\tIf objFSO.FileExists(strScripts & arrInstallers(i)) Then\n\t\t\t\t\t\tlogFile.WriteLine \"Copying: \" & arrInstallers(i)\n\t\t\t\t\t\tobjFSO.CopyFile strScripts & arrInstallers(i), strLocalDir, True\n\t\t\t\t\tEnd If\n\t\t\t\tEnd If\n\t\t\tNext\n\t\t\tErase arrSpecial\n\t\tEnd If\n\tNext\n\t\n\t' Check If This is An Initial Installation\n\tConst HKEY_LOCAL_MACHINE = &H80000002\n\tDim objRegistry: Set objRegistry = GetObject(\"winmgmts:\\\\\" & strComp & \"\\root\\default:StdRegProv\")\n\tDim strKeyPath: strKeyPath = \"SOFTWARE\\SCRIPTEDInstall\"\n\tDim strValueName: strValueName = \"InitialInstall\"\n\tDim strValue\n\tobjRegistry.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue\n\tIf IsNull(strValue) Then\n\t\tstrValue = \"1\"\n\t\tlogFile.WriteLine \"Initial Install Detected\"\n\t\tlogFile.WriteLine \"Creating Registry Key: HKL\\\" & strKeyPath & \"\\\" & strValueName & \"=\" & strValue\n\t\tobjRegistry.CreateKey HKEY_LOCAL_MACHINE,strKeyPath\n\t\tobjRegistry.SetStringValue HKEY_LOCAL_MACHINE, strKeyPath, strValueName, strValue\n\tElse\n\t\tlogFile.WriteLine \"NON-Initial Install Detected\"\n\t\tIf objFSO.FileExists(strLocalDir & \"02_SecurityHotfix.vbs\") Then\n\t\t\tlogFile.WriteLine \"Detected and Deleting: \" & strLocalDir & \"02_SecurityHotfix.vbs\"\n\t\t\tobjFSO.DeleteFile strLocalDir & \"02_SecurityHotfix.vbs\", True\n\t\tEnd If\n\t\tIf objFSO.FileExists(strLocalDir & \"92_SecurityHotfix.vbs\") Then\n\t\t\tlogFile.WriteLine \"Detected and Deleting: \" & strLocalDir & \"92_SecurityHotfix.vbs\"\n\t\t\tobjFSO.DeleteFile strLocalDir & \"92_SecurityHotfix.vbs\", True\n\t\tEnd If\n\tEnd If\n\n\t' Check If Installer Script Exists, Else Copy It\n\tIf Not objFSO.FileExists(objShell.ExpandEnvironmentStrings(\"%SystemRoot%\") & \"\\APPS\\runinst.vbs\") Then\n\t\tlogFile.WriteLine objShell.ExpandEnvironmentStrings(\"%SystemRoot%\") & \"\\APPS\\runinst.vbs Not Found\"\n\t\t' Ensure Installer Script Exists in Network Scripts\n\t\tIf objFSO.FileExists(strScripts & \"runinst.vbs\") Then\n\t\t\tlogFile.WriteLine \"Found and Copying runinst.vbs from Network Scripts\"\n\t\t\tobjFSO.CopyFile strScripts & \"runinst.vbs\", objShell.ExpandEnvironmentStrings(\"%SystemRoot%\") & \"\\APPS\\\", True\n\t\tElse\n\t\t\tlogFileWriteLine \"Error - Couldn't find runinst.vbs in \" & strScripts\n\t\tEnd If\n\tEnd If\n\t\n\t' Kill All Running Scripts Except This One to Ensure We Get A Clean Launch\n\tDim objWMIService: Set objWMIService = GetObject(\"winmgmts:\\\\.\\root\\cimv2\")\n\tDim colProcesses: Set colProcesses = objWMIService.ExecQuery(\"SELECT * FROM Win32_Process WHERE Name = \" & \"'Wscript.exe' OR Name = 'Cscript.exe' OR Name = 'cmd.exe'\")\n\tDim objProcess\n\tIf colProcesses.Count = 0 Then\n\t\tLogFile.WriteLine \"No scripts are running...\"\n\tElse\n\t\tFor Each objProcess in colProcesses\n\t\t\tIf InStr(objProcess.CommandLine, Wscript.ScriptName) Then\n\t\t\t\t' Current Script, Don't Do Anything\n\t\t\tElse\n\t\t\t\tLogFile.WriteLine \"Terminating Script \" & objProcess.CommandLine\t\t\t\t\n\t\t\t\tobjProcess.Terminate()\n\t\t\t\tWscript.Sleep(5000)\n\t\t\tEnd If\n\t\tNext\n\tEnd If\n\tWscript.Sleep(5000)\n\t\n\t' Launch Installer Script\n\tlogFile.WriteLine \"Launching runinst.vbs Installer Script\"\n\tobjShell.Run \"wscript.exe //e:vbscript \" & objShell.ExpandEnvironmentStrings(\"%SystemRoot%\") & \"\\APPS\\runinst.vbs \" & strLocalDir, 1, False\n\t\t\n\t' Close Log File\n\tlogFile.WriteLine \"Close and Kill \" & Wscript.ScriptName\n\tlogFile.Close\n\t\n\t' Kill Objects\n\tSet objFSO = nothing\n\tSet objShell = nothing\n\t\n\tOn Error GoTo 0\t ' End ProcessComputer Error Handling\n\nEnd Sub\n\n' ***************************************************************************************************\n' Sub ScriptSuicide - Self Deletes Script\n' ***************************************************************************************************\nPrivate Sub ScriptSuicide()\n\n\t' Ignore All Errors\n\tOn Error Resume Next\n\t\n\tDim objFSO: Set objFSO = CreateObject(\"Scripting.FileSystemObject\")\n\tobjFSO.DeleteFile WScript.ScriptFullName\n\t\n\t' Kill Objects\n\tSet objFSO = nothing\n\t\n\t' End Error Handling\n\tOn Error GoTo 0\n\t\nEnd Sub\n<\/code><\/pre>\n
01_AutoUpdate.vbs - Set’s WIndows updates:<\/strong><\/p>\n
'=========================================================================\n' AutoUpdate.vbs\n' AUTHOR: Sigkill\n' VERSION: 1.0\n' PURPOSE: Sets the Auto Update Options\n'\n'\n' COMMENTS: \n'=========================================================================\n' Force Explicit Variable Declaration\nOption Explicit\n\n' Call Main Execution Loop, and Quit with an Errorlevel of 0 When Done\nMain(): WScript.Quit(0)\n\n' ***************************************************************************************************\n' Sub Main\n' ***************************************************************************************************\nSub Main()\n\n\t' Ignore All Errors\n\tOn Error Resume Next\n\t\n\t' Create Objects\n\tDim objFSO: Set objFSO = CreateObject(\"Scripting.FileSystemObject\")\n\tDim objShell: Set objShell = CreateObject(\"WScript.Shell\")\n\t\n\t' Open Log File For Appending\n\tConst ForAppending = 8\n\tDim logFile: Set logFile = objFSO.OpenTextFile(objShell.ExpandEnvironmentStrings(\"%SystemRoot%\\setuplog1.log\"), ForAppending, True)\n\tlogFile.WriteLine VBCRLF & VBCRLF & \"==========================================================\"\n\tlogFile.WriteLine Wscript.ScriptName\n\tlogFile.WriteLine \"==========================================================\"\n\t\n\t' Connect to Registry\n\tDim strComputer: strComputer = \".\"\n\tDim objRegistry: Set objRegistry = GetObject(\"winmgmts:\\\\\" & strComputer & \"\\root\\default:StdRegProv\")\n\tDim strKeyPath: strKeyPath = \"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\WindowsUpdate\\Auto Update\"\n\tlogFile.WriteLine strKeyPath\n\t\n\t' Declare Registry Variables\n\tConst HKEY_LOCAL_MACHINE = &H80000002\n\tDim strValueName, strValue, dwValue\n\n\t' Update Install Option (4= Automatic Download and Install)\n\tstrValueName = \"AUOptions\"\n\tdwValue = 00000004\n\tobjRegistry.SetDWORDValue HKEY_LOCAL_MACHINE, strKeyPath, strValueName, dwValue\n\tLogFile.WriteLine strValueName & \"=\" & dwValue\n\t\n\t' Configure Version\n\tstrValueName = \"ConfigVer\"\n\tdwValue = 00000001\n\tobjRegistry.SetDWORDValue HKEY_LOCAL_MACHINE, strKeyPath, strValueName, dwValue\n\tLogFile.WriteLine strValueName & \"=\" & dwValue\n\n\t' Next Update Detection Time (Current Time + 5 Minutes)\n\tstrValueName = \"NextDetectionTime\"\n\tstrValue = Year(Date) & \"-\" & Month(Date) & \"-\" & Day(Date) & \" \" & FormatDateTime(DateAdd(\"N\", 5, Time), 4) & \":00\"\n\tobjRegistry.SetStringValue HKEY_LOCAL_MACHINE, strKeyPath, strValueName, strValue\n\tLogFile.WriteLine strValueName & \"=\" & strValue\n\n\t' Scheduled Update Install Date (Current Time + 1 Hour)\n\tstrValueName = \"ScheduledInstallDate\"\n\tstrValue = Year(Date) & \"-\" & Month(Date) & \"-\" & Day(Date) & \" \" & FormatDateTime(DateAdd(\"H\", 1, Time), 4) & \":00\"\n\tobjRegistry.SetStringValue HKEY_LOCAL_MACHINE, strKeyPath, strValueName, strValue\n\tLogFile.WriteLine strValueName & \"=\" & strValue\t\n\t\n\t' Scheduled Day(s) to Check for Updates (0 = Daily)\n\tstrValueName = \"ScheduledInstallDay\"\n\tdwValue = 00000000\n\tobjRegistry.SetDWORDValue HKEY_LOCAL_MACHINE, strKeyPath, strValueName, dwValue\n\tLogFile.WriteLine strValueName & \"=\" & dwValue\n\t\n\t' Scheduled Update Installation Time (3 = 3:00 AM)\n\tstrValueName = \"ScheduledInstallTime\"\n\tdwValue = 00000003\n\tobjRegistry.SetDWORDValue HKEY_LOCAL_MACHINE, strKeyPath, strValueName, dwValue\n\tLogFile.WriteLine strValueName & \"=\" & dwValue\n\t\n\t' Close Log File\n\tlogFile.Close\n\t\n\t' Kill Objects\n\tSet objFSO = nothing\n\tSet objShell = nothing\n\tSet objRegistry = nothing\n\t\n\t' End Error Handling\n\tOn Error GoTo 0\n\t\nEnd Sub\n<\/code><\/pre>\n
Then basically, just make a bunch of scripts (vbs, js, reg, etc) in the folder and number by the order you want them to install. For example: \n15_Firefox.bat<\/strong><\/p>\n
@echo off\n:==========================================================================\n: 15_Firefox.bat\n: AUTHOR: Sigkill\n: VERSION: 1.0\n: COMMENTS: Installs Mozilla Firefox\n: NOTES:\n:==========================================================================\nsetlocal \nset BATNAME=15_Firefox.bat\nset BATDESC=Mozilla Firefox\nset PATHTOINSTALL=\\\\SERVER\\install\\Apps\\firefox\n\necho. >>%SystemRoot%\\setuplog1.log\necho ========================================================== >>%SystemRoot%\\setuplog1.log\necho %BATNAME% %1 starting as %username% at %date% %time% >>%SystemRoot%\\setuplog1.log\necho ========================================================== >>%SystemRoot%\\setuplog1.log\n\necho **********************************************\necho ********************************************** >>%SystemRoot%\\setuplog1.log\necho * \necho * >>%SystemRoot%\\setuplog1.log\necho * %BATNAME% - %BATDESC% \necho * %BATNAME% - %BATDESC% >>%SystemRoot%\\setuplog1.log\necho * \necho * >>%SystemRoot%\\setuplog1.log\necho **********************************************\necho ********************************************** >>%SystemRoot%\\setuplog1.log\nGoto app1\n\n:app1\nset app1=Firefox 3\necho Checking if %app1% is installed\necho Checking if %app1% is installed >>%SystemRoot%\\setuplog1.log\necho.\necho. >>%SystemRoot%\\setuplog1.log\nIf Exist \"%PROGRAMFILES%\\Mozilla Firefox\\firefox.exe\" Goto skip_app1\n\n:install_app1\necho Now Starting %app1% installation...\necho Now Starting %app1% installation... >>%SystemRoot%\\setuplog1.log\nstart \"\" /wait \"%PATHTOINSTALL%\\Firefox Setup 3.0.exe\" /S\necho Finished Installing %app1%\necho Finished Installing %app1% >>%SystemRoot%\\setuplog1.log\necho.\necho. >>%SystemRoot%\\setuplog1.log\nGoto end\n\n:skip_app1\necho %app1% is already installed, skipping install\necho %app1% is already installed, skipping install >>%SystemRoot%\\setuplog1.log\necho.\necho. >>%SystemRoot%\\setuplog1.log\nGoto end\n\n:end\necho Completed Installation of %BATNAME%\necho Completed Installation of %BATNAME% >>%SystemRoot%\\setuplog1.log\necho ********************************************** \necho ========================================================== >>%SystemRoot%\\setuplog1.log\necho.\necho. >>%SystemRoot%\\setuplog1.log\necho.\necho. >>%SystemRoot%\\setuplog1.log\n<\/code><\/pre>","upvoteCount":1,"datePublished":"2015-01-10T20:34:46.000Z","url":"https://community.spiceworks.com/t/scripting-question/368834/12","author":{"@type":"Person","name":"briansteinmeyer8653","url":"https://community.spiceworks.com/u/briansteinmeyer8653"}},"suggestedAnswer":[{"@type":"Answer","text":"
Hi Spiceheads,<\/p>\n
I’m going to leave this in the PowerShell forum, admins feel free to move it.<\/p>\n
Im playing around with the idea of creating a script (or something) that would automate our laptop setups, something that will automatically install all our small programs like CutePDF and DWG Trueview. The main idea behind this is to save us some time when it comes to setting up a new laptop for a new user.<\/p>\n
I have written up (pen and paper) a rough draft of what I want it to do, but I’m so wet behind the ears when it comes to scripting that I make the Nile look tad dehydrated.<\/p>\n
So the question is this: Is it possible to write a script that will pull the installers from a network location and install the programs on a laptop automatically?<\/p>\n
Aside: Have you done this? How did you go about writing the script or whatever you used for it?<\/p>\n
Thanks in advance…<\/p>","upvoteCount":10,"datePublished":"2015-01-07T11:16:19.000Z","url":"https://community.spiceworks.com/t/scripting-question/368834/1","author":{"@type":"Person","name":"anton-thecat","url":"https://community.spiceworks.com/u/anton-thecat"}},{"@type":"Answer","text":"
Might be easier if you look at PDQ Deploy or Spec ops Deploy.<\/p>\n
Possible yes, but how much time would you have to spend developing the in house solution compared to $250.00 USD for a one year license of PDQ Deploy?<\/p>","upvoteCount":5,"datePublished":"2015-01-07T11:25:11.000Z","url":"https://community.spiceworks.com/t/scripting-question/368834/2","author":{"@type":"Person","name":"Little-Green-Man","url":"https://community.spiceworks.com/u/Little-Green-Man"}},{"@type":"Answer","text":"
If you can get all the apps to deploy silently via MSI, try a GPO that does it instead. Apply it to a special OU that you can dump the machines in while you set them up. A few reboots and POW! you’ll be good to go.<\/p>","upvoteCount":5,"datePublished":"2015-01-07T11:32:18.000Z","url":"https://community.spiceworks.com/t/scripting-question/368834/3","author":{"@type":"Person","name":"danchamberlain","url":"https://community.spiceworks.com/u/danchamberlain"}},{"@type":"Answer","text":"
Definitely need to look into a deployment product. I can’t recommend the Microsoft Deployment Toolkit enough. There’s definitely a learning curve, but there are plenty of guides out there for basic setups.<\/p>\n
Two years ago I moved our organization off of an expensive third party deployment tool to MDT which saved us tons of cost and is a much more flexible solution overall. We went from deploying separate images based on model to a single each image for each processor architecture with applications that can be dynamically deployed at image time.<\/p>\n
And it’s free and integrates with Configuration Manager!<\/p>\n
If you don’t really need an imaging/deployment solution, there are other options out there like Chocolatey/Boxstarter that could help you with package management. GPOs as suggested by TheHugLife are fine but limited since you can only use MSI installers.<\/p>\n
Application installs is something I typically don’t do much with Powershell, but it’s definitely possible. However, there is no single solution since every application is different and usually has it’s own requirements for unattended installations.<\/p>","upvoteCount":6,"datePublished":"2015-01-07T11:42:48.000Z","url":"https://community.spiceworks.com/t/scripting-question/368834/4","author":{"@type":"Person","name":"mattmcnabb","url":"https://community.spiceworks.com/u/mattmcnabb"}},{"@type":"Answer","text":"