Windows 10 msiexec noreboot option

robertkwild

Active Member
whats wrong with this command as i dont want it to restart after it uninstalls sep but it restarts

start /wait MsiExec.exe /X {8097EE64-FDE1-409A-B25D-3DFD862871E1} /passive /norestart
 
Looks fine to me. You can copy and paste this script into a vbs file. It will silently uninstall SEP and not reboot. I use this at work to remove software. You can also edit the RemoveCurrentInstalls "Symantec Endpoint" to match any software for the future you need to remove.

Code:
Option Explicit
const HKEY_LOCAL_MACHINE = &H80000002

Dim objWshShell, objWMI, WinDir, RegExp
Dim colWin32_ComputerSystem, objWin32_ComputerSystem
Dim strSoftwareName, strApplicationType
Dim strSystemType, strProgramFiles, strSoftwareRegistryKey

Set objWshShell = WScript.CreateObject("WScript.Shell")
Set objWMI = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\.\root\cimv2")
WinDir = objWshShell.ExpandEnvironmentStrings("%windir%")
Set RegExp = new RegExp
RegExp.IgnoreCase = true


On Error Resume Next


strSystemType = "x32"
Set colWin32_ComputerSystem = objWMI.ExecQuery ("Select * from Win32_ComputerSystem")
For Each objWin32_ComputerSystem in colWin32_ComputerSystem
    If objWin32_ComputerSystem.SystemType = "x64-based PC" Then
        strSystemType = "x64"
    End If
Next

SetApplicationPathItems "32-bit"
RemoveCurrentInstalls "Symantec Endpoint"

SetApplicationPathItems "64-bit"
RemoveCurrentInstalls "Symantec Endpoint"

Wscript.Quit





' ~$~----------------------------------------~$~
'        STANDARD FUNCTIONS & SUBROUTINES
' ~$~----------------------------------------~$~
Sub SetApplicationPathItems(strAppType)
'Setting the path to the correct ""Program Files"" folder and ""SOFTWARE"" registry key based on the application and OS type
strApplicationType = strAppType
If strSystemType = "x64" Then
    If strApplicationType = "64-bit" Then
        strSoftwareRegistryKey = "SOFTWARE"
        If UCase(Wscript.FullName) = UCase(WinDir & "\SysWOW64\WScript.exe") Then
            'Installing a 64-bit application on a 64-bit OS from a 32-bit wscript.exe process
            strProgramFiles = objWshShell.ExpandEnvironmentStrings("%ProgramW6432%")
        Else
            'Installing a 64-bit application on a 64-bit OS from a 64-bit wscript.exe process
            strProgramFiles = objWshShell.ExpandEnvironmentStrings("%ProgramFiles%")
        End If
    Else
        strSoftwareRegistryKey = "SOFTWARE\Wow6432Node"
        'Installing a 32-bit application on a 64-bit OS (the wscript.exe process type does not matter)
        strProgramFiles = objWshShell.ExpandEnvironmentStrings("%ProgramFiles(x86)%")
    End If
Else
    strSoftwareRegistryKey = "SOFTWARE"
    'Installing a 32-bit application on a 32-bit OS from a 32-bit wscript.exe process
    strProgramFiles = objWshShell.ExpandEnvironmentStrings("%ProgramFiles%")
End If
End Sub

' ~$~----------------------------------------~$~
Sub RemoveCurrentInstalls(strValueCheck)
Dim objReg, strKeyPath, subkey, arrSubKeys, strValue, strCheckKey, intArrayCount, arrUninstallString, x
Dim strUninstallString, intStringLength, intUninstallReturn
strUninstallString = ""
arrUninstallString = Array()
intArrayCount = 0
strKeyPath = strSoftwareRegistryKey & "\Microsoft\Windows\CurrentVersion\Uninstall"
Set objReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv")
objReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubKeys
For Each subkey In arrSubKeys
    strValue = ""
    strCheckKey = strKeyPath & "\" & subkey
    objReg.GetStringValue HKEY_LOCAL_MACHINE,strCheckKey,"DisplayName",strValue
    If Not IsNull(strValue) Then
        RegExp.pattern = strValueCheck
        If (RegExp.test (strValue) = TRUE) Then
            ' Attempts to obtain the UninstallString for the matching string.
            objReg.GetStringValue HKEY_LOCAL_MACHINE,strCheckKey,"UninstallString",strValue
            reDim preserve arrUninstallString(UBound(arrUninstallString) +1)
            arrUninstallString(intArrayCount) = strValue
            intArrayCount = intArrayCount + 1
        End If
    End If
Next
For x = LBound(arrUninstallString) to UBound(arrUninstallString)
    strUninstallString = arrUninstallString(x)
    If UCase(Left(strUninstallString, 14)) = UCase("MsiExec.exe /I") Then
        'Adjusting the uninstall string to fix known oddities
        intStringLength = Len(strUninstallString)
        strUninstallString = Left(strUninstallString, 13) & "X " & Right(strUninstallString, intStringLength - 14)
    End If
    intUninstallReturn = objWshShell.Run (strUninstallString & " /quiet /norestart", 1, True)
Next
End Sub
 
Back
Top