amar3181 Posted March 27, 2015 Share Posted March 27, 2015 Trying to uninstall an exe. RunWait("'" & @ProgramFilesDir & "\OCS Inventory Agent\uninst.exe' /S") RunWait(@ComSpec & " /c " & "rmdir '" & @ProgramFilesDir & "\OCS Inventory Agent' /Q /S", "", @SW_HIDE) Does not seem to work. The command is correct as tested it in cmd. Any thing I am missing Link to comment Share on other sites More sharing options...
jguinch Posted March 27, 2015 Share Posted March 27, 2015 Does this code work ? RunWait(@ProgramFilesDir & "\OCS Inventory Agent\uninst.exe /S") DirRemove(@ProgramFilesDir & "\OCS Inventory Agent", 1) Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF Link to comment Share on other sites More sharing options...
amar3181 Posted March 27, 2015 Author Share Posted March 27, 2015 First part works ... Uninstall done. Dir does not get deleted though. Link to comment Share on other sites More sharing options...
Developers Jos Posted March 27, 2015 Developers Share Posted March 27, 2015 (edited) First part works ... Uninstall done. Dir does not get deleted though. Do you get an UAC prompt for the uninstall command? If so then run then script with #RequireAdmin. Jos Edited March 27, 2015 by Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
ViciousXUSMC Posted March 27, 2015 Share Posted March 27, 2015 (edited) Definitely try #RequireAdmin since its a ProgramFiles change. Also if files are still held open in the os briefly after uninstall it may fail, I have seen issues like that, usually they free up after a few seconds so you can try a loop of sorts. Worst case though it may need a reboot or a manual close of files/services if that is what is blocking you. $retrycount = 5 Do If FileExists(@ProgramFilesDir & "\OCS Inventory Agent\") Then DirRemove(@ProgramFilesDir & "\OCS Inventory Agent", 1) Sleep(2000) $retrycount -=1 Else ExitLoop EndIf Until $retrycount = 0 Edited March 27, 2015 by ViciousXUSMC Link to comment Share on other sites More sharing options...
amar3181 Posted March 27, 2015 Author Share Posted March 27, 2015 Used #RequireAdmin but still not able to delete the folder. No files open after uninstall.. Link to comment Share on other sites More sharing options...
Developers Jos Posted March 27, 2015 Developers Share Posted March 27, 2015 (edited) Used #RequireAdmin but still not able to delete the folder. No files open after uninstall.. The key here is whether or not the uninstall process is still running when you are doing the DirRemove() command. This could happen when the RunWait() shelled program shells another process and ends. Jos Edited March 27, 2015 by Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
amar3181 Posted March 27, 2015 Author Share Posted March 27, 2015 Ok But this being Runwait the switch to Dirremove will happen once the previous is complete right? In any case I am just running the code to delete folder independently but still no success Link to comment Share on other sites More sharing options...
Developers Jos Posted March 27, 2015 Developers Share Posted March 27, 2015 (edited) Ok But this being Runwait the switch to Dirremove will happen once the previous is complete right? In any case I am just running the code to delete folder independently but still no success Yes BUT: let me try to explain in a little more detail what I tried to say in my last post: You shell program UNINST.EXE from the OCS program directory and are waiting for it to finish. It could very well be that this UNINST.exe program will start another uninstall program and then terminate. The result would be that the "real" uninstall program is still running while the AutoIt3 script sees that the original shelled program ended. Have you used the standard OCS installer and which version? (I have it also installed so could have a more details look later) Jos Edited March 27, 2015 by Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
amar3181 Posted March 27, 2015 Author Share Posted March 27, 2015 OCS 4061.1 I will also try it on a fresh host to be sure. Link to comment Share on other sites More sharing options...
jguinch Posted March 27, 2015 Share Posted March 27, 2015 I can confirm what JOS said : the uninst.exe start a child process (name is AU_.exe on my system) So this should work : $iPID = Run ("C:\Program Files (x86)\OCS Inventory Agent\uninst.exe /s") $iChlidProcess = ProcessWait("Au_.exe") ProcessWaitClose($iChlidProcess) DirRemove("C:\Program Files (x86)\OCS Inventory Agent", 1) You can also use this king of code : $iPID = Run ("C:\Program Files (x86)\OCS Inventory Agent\uninst.exe /s") _ProcessWaitCloseRec($iPID) DirRemove("C:\Program Files (x86)\OCS Inventory Agent", 1) Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF Link to comment Share on other sites More sharing options...
amar3181 Posted March 30, 2015 Author Share Posted March 30, 2015 I had a question. Above we are waiting on the child process spawned to complete. Won't this result in a deadlock as it does not end anytime soon? Any idea if we can force it to kill after the work is done? Link to comment Share on other sites More sharing options...
amar3181 Posted March 30, 2015 Author Share Posted March 30, 2015 $iPID = Run ("C:\Program Files (x86)\OCS Inventory Agent\uninst.exe /s") $iChlidProcess = ProcessWait("Au_.exe") ProcessWaitClose($iChlidProcess) DirRemove("C:\Program Files (x86)\OCS Inventory Agent", 1) Tried this but the script remains paused ... Link to comment Share on other sites More sharing options...
Zedna Posted March 30, 2015 Share Posted March 30, 2015 (edited) Maybe it will be simpler to check (in loop) when target directory gets empty (when it becomes empty) and then do DirRemove(). This way you don't need to check any running/closing processes. Edited March 30, 2015 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search 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