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

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
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,213,544
Messages
6,114,249
Members
448,556
Latest member
peterhess2002

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