[SOLVED] need help with a batch file .bat

perrynick17

Honorable
BANNED
Dec 30, 2018
131
1
10,615
I want to make a self running batch file that will allow me to run chkdsk /r without having the user press y and ENTER to confirm the checking on system startup.

so far I have the batch file set to launch the chkdsk /r command as an admin using
set "params=%*"
cd /d "%~dp0" && ( if exist "%temp%\getadmin.vbs" del "%temp%\getadmin.vbs" ) && fsutil dirty query %systemdrive% 1>nul 2>nul || ( echo Set UAC = CreateObject^("Shell.Application"^) : UAC.ShellExecute "cmd.exe", "/k cd ""%~sdp0"" && %~s0 %params%", "", "runas", 1 >> "%temp%\getadmin.vbs" && "%temp%\getadmin.vbs" && exit /B )
chkdsk /r

what can i add to this to get the press y and then the enter key to complete this with no user interaction

im doing a large scale pc refreshing and i want to email each user this bat file and run it after they all have it on their desktop

and how could i send a restart command so the pc will auto restart
 
Last edited:
Solution
shutdown /r /t 0 is command for restart
chkntfs /c is command to schedule checkdisk on next boot
u can also use fsutil dirty set to make ur drive think it needs repair on next boot (fsutil needs to be installed first tho)
I want to make a self running batch file that will allow me to run chkdsk /r without having the user press y and ENTER to confirm the checking on system startup.

....

what can i add to this to get the press y and then the enter key to complete this with no user interaction

im doing a large scale pc refreshing and i want to email each user this bat file and run it after they all have it on their desktop
If I were an employee, I'd be immediately suspect of any email that said "Run this batch file"
No matter WHO it came from.

Especially even if it was "our network guy".

Emails like this are frequently used as a security test. See who falls for it.
Anyone who downloads and runs that file, fails the test.

This should be done via the network, pushed via group policy.
No user interaction at all.

"Leave your systems running Tuesday night. We'll be running a script starting at 11PM."
 
  • Like
Reactions: Corwin65
If I were an employee, I'd be immediately suspect of any email that said "Run this batch file"
No matter WHO it came from.

Especially even if it was "our network guy".

Emails like this are frequently used as a security test. See who falls for it.
Anyone who downloads and runs that file, fails the test.

This should be done via the network, pushed via group policy.
No user interaction at all.

"Leave your systems running Tuesday night. We'll be running a script starting at 11PM."
ohhoo big scary batch file watch out
 
I want to make a self running batch file that will allow me to run chkdsk /r without having the user press y and ENTER to confirm the checking on system startup. and how could i send a restart command so the pc will auto restart

so far I have the batch file set to launch the chkdsk /r command as an admin using
set "params=%*"
cd /d "%~dp0" && ( if exist "%temp%\getadmin.vbs" del "%temp%\getadmin.vbs" ) && fsutil dirty query %systemdrive% 1>nul 2>nul || ( echo Set UAC = CreateObject^("Shell.Application"^) : UAC.ShellExecute "cmd.exe", "/k cd ""%~sdp0"" && %~s0 %params%", "", "runas", 1 >> "%temp%\getadmin.vbs" && "%temp%\getadmin.vbs" && exit /B )
chkdsk /r

what can i add to this to get the press y and then the enter key to complete this with no user interaction

im doing a large scale pc refreshing where all the systems are independent, and i want to email each user this bat file and run it after they all have it on their desktop

and how could i send a restart command so the pc will auto restart