Batch script command to by pass pressing OK.

S.H.A.D.O.

Well-known Member
Joined
Sep 6, 2005
Messages
1,915
Good evening,

I hope this is the right place to post this?

I want to run the below command in a batch script.
It does actually work fine but I have to press "OK" for it to continue or "Cancel" to not.
How can I adapt the script below so it automatically presses the "OK" for me in the script please?
I don't want the popup box to appear.
I have tried /Q at the end, I have also tried Click [OK] but to no avail.
Any help will be greatly appreciated.

Code:
echo off
echo.
echo [12] Running extended cleanup...
cd C:\windows\system32 
%SystemRoot%\System32\Cmd.exe /c Cleanmgr /sageset:65535 & Cleanmgr /sagerun:65535
echo. & echo This process completed successfully. & echo. & pause & cls
exit

Thanks in advance.
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
Hi S.H.A.D.O.,
not tested but give it a go

Code:
echo off
echo.
echo [12] Running extended cleanup...
cd C:\windows\system32 
[COLOR=#ff0000]Shell("[/COLOR]%SystemRoot%\System32\Cmd.exe /c Cleanmgr /sageset:65535 & Cleanmgr /sagerun:65535[COLOR=#ff0000]")[/COLOR]
echo. & echo This process completed successfully. & echo. & pause & cls
exit

Have a nice evening
 
Upvote 0
Thanks for the reply B___P, it is appreciated.

Unfortunately that gives me an error saying:

'Shell' is not recognised as an internal or external command, operable program or batch file.

Thanks in advance.
 
Upvote 0
Sorry S.H.A.D.O.,
I thought it was a kind of vb script but it is part of a bat file.
Change
Code:
%SystemRoot%\System32\Cmd.exe /c Cleanmgr /sageset:65535 & Cleanmgr /sagerun:65535
to
Cleanmgr /sageset:65535 & Cleanmgr /sagerun:65535
I think you do not need to run cmd.exe ...

Hope this helps
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,182
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top