Sign in to follow this  
Followers 0
chaoticyeshua

psexec and regread

3 posts in this topic

Hello,

I compiled a script on a 64-bit computer, and the script is not working properly on 32-bit computers. Here's what I'm trying to do... We are, as a university, switching from Symantec to Microsoft Forefront Endpoint Protection. However, on some machines, Symantec is failing to remove through the use of our SCCM server. Instead, I am using psexec to run this script which finds the GUID of Symantec, initiates an msiexec uninstall, and then installs Forefront. If run on a 64-bit test machine, it seems to work flawlessly. However, every 32-bit machine I've pushed the script to does not remove Symantec. I'm assuming this is because it isn't reading the registry for the GUID properly. Any thoughts? I'm spinning up a 32-bit Windows 7 machine right now for some testing of my own. But if anyone has any input, I'd really appreciate it.

; Find the GUID for Symantec
$index = 1
$GUID = ""

If @OSArch="X86" Then
$keyroot = "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"
Else
$keyroot = "HKLM64\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"
EndIf

$subkey = "***START***"; we use this because "" will make our While loop exit
While $subkey <> ""
$subkey = RegEnumKey($keyroot, $index)

If StringInStr(RegRead($keyroot & "\" & $subkey, "DisplayName"), _
"Symantec") Then
$GUID = $subkey ; Record the GUID
$subkey = "" ; Force the While to exit
EndIf

$index = $index + 1
WEnd

If $GUID <> "" Then
ShellExecuteWait('msiexec',"/qn /X" & $GUID & " /norestart")
Sleep(30000)
RunWait("\\server\share\Forefront Protection\FEPInstall(" & @OSArch & ").exe /q /s")
EndIf

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

your root's aren't correct

Switch @OSArch
Case "X64"
  Global $gsRegistryUninstall = "HKEY_LOCAL_MACHINESOFTWAREWow6432NodeMicrosoftWindowsCurrentVersionUninstall"
Case "X86"
  Global $gsRegistryUninstall = "HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindowsCurrentVersionUninstall"
Case Else
  MsgBox ( 1,1, "Unknown @OSArch type=[" & @OSArch & "]")
EndSwitch

i use the above...not sure of other configs...but, maybe you do install there, just posting what works for me :)

Edited by jdelaney

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

Share this post


Link to post
Share on other sites

Thanks, that seems to have fixed it even though the root key for x86 was the same and that's the architecture I'm having problems with. Not sure why, but it worked!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0