RMP Posted October 1, 2018 Posted October 1, 2018 Need help adding DirRemove to my script. Need to remove two folders after the uninstall runs, one from Program Files x86, and ProgramData. My Script so far. #RequireAdmin ; Set log file location based on command line argument. if $cmdline[0] = 0 Then $logfile = @TempDir & "\" & @ScriptName & ".log" Else $logfile = $cmdline[1] EndIf RunWait("MsiExec /X{1A898D41-7BAB-4DF0-A8AE-430BE77AF3C8} /qn /norestart") func _CurrentDateTime() return @MON & "/" & @MDAY & "/" & @YEAR & " " & @HOUR & ":" & @MIN & ":" & @SEC EndFunc func _checkExitCode($ExitCode, $PatchName) if $ExitCode = 3010 OR $ExitCode = 0 OR $ExitCode = 1605 Then FileWriteLine($logfile, "[" & _CurrentDateTime() & "] " & $PatchName & " uninstalled successfully, exit code: " & $ExitCode ) $ExitCode = 0 Else FileWriteLine($logfile, "[" & _CurrentDateTime() & "] " & $PatchName & " failed to uninstall, exit code: " & $ExitCode ) Exit($ExitCode) EndIf endfunc
Subz Posted October 1, 2018 Posted October 1, 2018 So what exactly is the problem? Just add DirRemove function after RunWait or is their something I'm missing?
benched42 Posted October 1, 2018 Posted October 1, 2018 In Windows 10, you will be prompted through UAC to remove any folders/files from the "Program Files", "Program Files (x86)" and "Program Data" folders. Well, unless you have UAC set to not prompt. At work, I no longer install my scripts or their data in those folders; instead I store them in a directory I create in the user's profile directory. Who lied and told you life would EVER be fair?
Subz Posted October 1, 2018 Posted October 1, 2018 @benched42#RequiredAdmin at the top of the OPs script will prompt for UAC if enabled, and as his script shows, he's uninstalling an existing program not creating a new installation.
benched42 Posted October 1, 2018 Posted October 1, 2018 At home, I have UAC turned off on my workstation, but I have the default setting for her laptop (I didn't change it and she doesn't know how). When I was removing software from her laptop this past weekend, I got the UAC prompt on her system. You get the prompt because changes are being made to the computer, to the point, more than one user's profile on the computer. At work we have our computers locked down to the point that a user can't install new software (outside of our Software Center from SCCM) or hardware without contacting our Service Desk for a one-time keycode to use to install said hardware and software. That's why I choose to install any of my scripts in the user's profile - no UAC prompt. Who lied and told you life would EVER be fair?
Subz Posted October 1, 2018 Posted October 1, 2018 As mentioned the OP has #RequireAdmin so it will prompt if the user doesn't have Admin rights and/or UAC is enabled, the rest of the script should then run in elevated mode. The problem with user based installs is you have to install it for every user that logs on, so only ideal for small scripts. When using SCCM you don't get prompted for UAC because the installer runs as the "System" account. However with SCCM using the "Package" mode, you can chain installs/scripts for example I configure the main application to install using "System" account then for each user that logs on, I have them run a script which configures user settings. Anyway kind of off topic of what the OP has asked.
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