Sign in to follow this  
Followers 0
amar3181

EXE uninstall

14 posts in this topic




First part works ... Uninstall done. Dir does not get deleted though. 

Share this post


Link to post
Share on other sites

#4 ·  Posted (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 by Jos

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#5 ·  Posted (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 by ViciousXUSMC

Share this post


Link to post
Share on other sites

Used #RequireAdmin but still not able to delete the folder.

No files open after uninstall..

Share this post


Link to post
Share on other sites

#7 ·  Posted (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 by Jos

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

#9 ·  Posted (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 by Jos

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

OCS 4061.1

I will also try it on a fresh host to be sure.

Share this post


Link to post
Share on other sites

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)

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
Share on other sites

$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 ...

Share this post


Link to post
Share on other sites

#14 ·  Posted (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 by Zedna

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