set service = GetObject ("winmgmts:") Set oNet= WScript.CreateObject("WScript.Network") Set WshShell = CreateObject("WScript.Shell") Set fso = CreateObject("Scripting.FileSystemObject") Const ForAppending = 8 Const CreateIfNotExist = True Const OpenAsASCII = 0 oComputer = oNet.ComputerName ' Get Default gateway to set InstallSource properly Set objWMIService = GetObject("winmgmts:\\" & oComputer & "\root\CIMV2") Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration Where IPEnabled = True") For Each objItem In colItems strIPAddress = Join(objItem.IPAddress, ",") strDefaultIPGateway = Join(objItem.DefaultIPGateway, ",") Next Dim ProcessName Dim UninstallSource Dim InstallSource Dim SuccessLogFile Dim FailureLogFile Dim InstalledExe Dim FontTarget ProcessName = "setup.exe" UninstallSource = "\\domain\apps\Private\Autodesk\Tools\UninstallProducts.vbs" FontTarget = """C:\Program Files\Autodesk\AutoCAD 2014\Fonts\""" InstallSource = "\\domain\apps\Private\Autodesk\Tools\AutoCAD_2014_Network.lnk" if strDefaultIPGateway = "192.168.6.1" Then InstallSource = "\\branch1\apps$\Autodesk\Tools\AutoCAD_2014_Network.lnk" End if if strDefaultIPGateway = "192.168.7.1" Then InstallSource = "\\branch2\apps$\Autodesk\Tools\AutoCAD_2014_Network.lnk" End if if strDefaultIPGateway = "192.168.9.1" Then InstallSource = "\\branch3\apps$\Autodesk\Tools\AutoCAD_2014_Network.lnk" End if SuccessLogFile = "\\domain\apps\Private\Autodesk\Log\AutoCAD_2014_Network_Success.csv" FailureLogFile = "\\domain\apps\Private\Autodesk\Log\AutoCAD_2014_Network_Failure.csv" InstalledExe = "C:\Program Files\Autodesk\AutoCAD 2014\acad.exe" 'Check for product in file system If NOT (fso.FileExists(InstalledExe)) then ' If it doesn't exist, continue 'uninstall prior versions of the product WshShell.Run UninstallSource, 0, true 'install using Autodesk Deployment shortcut WshShell.Run(InstallSource) ' Begin loop to check for completion of installation do until Ended = 1 Ended = 1 ' Check for running process for each Process in Service.InstancesOf ("Win32_Process") If Process.Name = ProcessName then Ended = 0 End If next 'Sleep the script for 5 minutes before continuing loop to re-check wscript.sleep 300000 ' Loop back to the top to re-check the Installation status. This will continue until the process isn't running loop 'Delete any extra shortcuts as necessary If fso.FileExists("C:\Users\Public\Desktop\Autodesk ReCap.lnk") then fso.DeleteFile "C:\Users\Public\Desktop\Autodesk ReCap.lnk" End If If fso.FileExists("C:\Users\Public\Desktop\Autodesk 360.lnk") then fso.DeleteFile "C:\Users\Public\Desktop\Autodesk 360.lnk" End If 'Add standardized OSW shortcut for product fso.CopyFile "\\domain\apps\Private\Autodesk\Tools\Shortcuts\AutoCAD 2014.lnk", "C:\Users\Public\Desktop\AutoCAD 2014.lnk", True WshShell.run ("cmd.exe /c icacls ""C:\Users\Public\Desktop\AutoCAD 2014.lnk"" /Q /grant "".\Users"":M") 'Grant permission so user can delete shortcut 'Add any extra customizations or files as necessary 'Install Acroplot WshShell.Run "\\domain\apps\Private\General\AcroPlotPro\Acroplot_2014_Install.vbs", 0, true 'Copy Fonts WshShell.Run "\\domain\apps\Private\Autodesk\Tools\CopyFonts.vbs " &FontTarget , 0, true 'Log success/error to specific location If (fso.FileExists(InstalledExe)) then Set oFileText = fso.OpenTextFile(SuccessLogFile,ForAppending,CreateIfNotExist,OpenAsASCII) oFileText.WriteLine ""& oComputer & "," & Date & "," & Time Else Set oFileText = fso.OpenTextFile(FailureLogFile,ForAppending,CreateIfNotExist,OpenAsASCII) oFileText.WriteLine ""& oComputer & "," & Date & "," & Time End If End If