izzi13 Posted September 25, 2013 Share Posted September 25, 2013 Hi everyone. I'm new to autoit, and have very little VB knowledge. I'm trying to create an Autoit script to uninstall a Click-Once application and install a newer non-click-once version. I've gotten everything to work for the most part but there are a few things I'm not sure how to do or why they don't seem to work. Here is a copy of my script with all mo notations. expandcollapse popup;--------------------------------------------------------------------------------------- ;Script allows us to install multiple applications with-in one software package ;without the use of chaining. I'm also checking for application status codes ;at the end of each Runwait to make sure I should go to the next package ;If I get an error, I exit the script and pass in the failed status code ;---------------------------------------------------------------------------------------- ;All of what you see is cobbled together from what little I know of VB, and references I found on the internet. ;Stop NextBar process if running If ProcessExists("NextBar.exe") Then ProcessClose("NextBar.exe") EndIf ;Setting regpath to a $regpath so I can verify that it exists. If I didn't do this the if statement below didn't seem to work right $regpath = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\7C3FB5C3-F401-47FD-A7BD-19844F57BB13" ;Uninstall NextBar Installer ;I'm hoping this works as I planned. I'm not getting any errors if this path doesnt exist so I'm assuming it is doing what it's supposed to If $regpath = True Then RunWait("MsiExec.exe /X{7C3FB5C3-F401-47FD-A7BD-19844F57BB13} /passive REBOOT=ReallySuppress") Else Return False EndIf Sleep (3000) ;Uninstall Click Once version of NextBar ;How can I check and see if the regkey exists HKEY_Users\LOGGED on User\software\microsoft\windows\currentversion\uninstall\88cdb2567667c01e2? ;if it does exist I want to run the below uninstall command. ;As it is now the uninstall command runs regardless if it exists or not ;if the uninstall command runs and the application doesnt exist they get an error that I need to click on an ok button to proceed ;If it does exist and the command runs a confirmation windows is displayed asking if they want to remove the application. I need to click OK to proceed. ;Both windows have the word Maintenance in the title so I thought if I keyed of that I could catch both windows regardless and send the needed OK mouse click, ;but that didn't seem to work so I came up with the $title = option. Not sure if the winwait is working as on a VM it just seems to skip through the script. Run("rundll32.exe dfshim.dll,ShArpMaintain NextBar.application, Culture=en, PublicKeyToken=2a35befde721926b, processorArchitecture=x86") Sleep(4000) $title = WinGetTitle("") WinWaitActive($title) ControlClick($title, "", "[CLASS:WindowsForms10.BUTTON.app.0.21af1a5_r16_ad1; INSTANCE:1]") ;click ok Sleep(3000) ;remove regkey for NextBar installer ;When the NextBar installer uninstalls it doesn't get rid of this regkey so I'm just trying to clean everything up by deleting it. ; not sure if this is actually working as designed. I know it is deleting the regkey if it exists. I'm not getting any prompts if it doesn't so maybe it is. If $regpath = True Then RegDelete("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\7C3FB5C3-F401-47FD-A7BD-19844F57BB13") Else Return False EndIf Sleep (2000) ; Upgrade/install new version of NextBar RunWait("msiexec /i NextBarClientSetup.msi /passive REBOOT=ReallySuppress ALLUSERS=1") Any information or help you can provide is greatly appreciated. Thanks Ron Link to comment Share on other sites More sharing options...
JohnOne Posted September 25, 2013 Share Posted September 25, 2013 (edited) ;Setting regpath to a $regpath so I can verify that it exists. If I didn't do this the if statement below didn't seem to work right $regpath = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\7C3FB5C3-F401-47FD-A7BD-19844F57BB13" ;Uninstall NextBar Installer ;I'm hoping this works as I planned. I'm not getting any errors if this path doesnt exist so I'm assuming it is doing what it's supposed to If $regpath = True Then RunWait("MsiExec.exe /X{7C3FB5C3-F401-47FD-A7BD-19844F57BB13} /passive REBOOT=ReallySuppress") Else Return False EndIf That will most likely runwait whether that key exists or not. Just means it's not 0, False or an empty string. You should use RegRead to verify. EDIT: I'm curious, where does the title "HKEY_USERS" come from. Edited September 25, 2013 by JohnOne AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
izzi13 Posted September 25, 2013 Author Share Posted September 25, 2013 HKEY_USERS is part of the windows registry. In order for me to be able to read it I would have to find some way of loading it by getting the GUID of the logged on user which I don't know how to do. I've tried the regread option but it didn't work because I'm looking for that specific reg hive not a REG_SZ, or DWORD value. Link to comment Share on other sites More sharing options...
JohnOne Posted September 25, 2013 Share Posted September 25, 2013 (edited) Look at this to test if key exists $path = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\7C3FB5C3-F401-47FD-A7BD-19844F57BB13" $Goodpath = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion" Local $var = RegRead($Goodpath, "bullshit") MsgBox(4096, 'Good key', @error) Local $var = RegRead($path, "bullshit") MsgBox(4096, 'Test key', @error) Edited September 25, 2013 by JohnOne AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now