Jump to content

Click OK button after Batch Command has finished

Recommended Posts

Good evening,

I have been having trouble with getting a Batch Script to click "OK" after the Batch Command has finished . . .


On investigation, I came across this site which might help me resolve this.

Here is the part of the Batch Command that I am having trouble with . . .

cleanmgr.exe /VeryLowDisk /d C

Everything else in the Batch Script is automated and runs without ANY problems.

Is there a way that I can incorporate an Autoit Command to replicate [ virtual ] pressing the "OK" button please?

Stay SAFE, Best Regards.

Link to post
Share on other sites

Sorry, I could NOT find a way to edit my above post.

I should have mentioned that "OK" is obviously the ONLY option available, so the focus is on it. By that, I mean that getting the Script to replicate pressing ENTER, will also work.


Link to post
Share on other sites

You could also use /sageset, /sagerun switches for example the code below should be the same as running "cleanmgr.exe /VeryLowDisk" (untested).  The script would be the same checking every box in cleanmgr and then clicking ok, without any dialogue.
note: sageset/sagerun doesn't support the /d option.

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
;~ Use StateFlagsxxxx, where xxxx is 0 - 9999
Local $sStateFlags = "StateFlags0100"
Local $sVolumeCacheRoot = "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches"
Local $sVolumeCacheKey
Local $i = 1
While 1
    $sVolumeCacheKey = RegEnumKey($sVolumeCacheRoot, $i)
        If @error Then ExitLoop
    ;~ Uncomment line below to write to registry
    ;~  RegWrite($sVolumeCacheRoot & "\" & $sVolumeCacheKey, $sStateFlags, "REG_DWORD", 2)
    $i += 1
;~ Uncomment to run cleanmgr
;~ Run("cleanmgr.exe /sagerun:100")


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
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...