View Full Version : Windows Batch Files?
mizzfit
05-19-2008, 08:50 PM
Hi Everybody,
I am trying to script a batch file to run chkdsk on demand. This would be exectuted manually on a remote computer when I execute the script.
echo y | chkdsk c: /f /r /x && restart -r -t 5
When I do this it won't execute the reboot, it just stalls and execute only the first command.
Thanks in advance for any assistance,
mizzfit
EzyStvy
05-20-2008, 06:21 AM
Need to replace the word reboot with Shutdown.exe
Creating a Shutdown/Reboot Icon
WindowsXP has a program called SHUTDOWN.EXE which allows you to easily create icons to shutdown or restart your computer.
To create a shutdown shortcut on the desktop:
Right click on an open area of the desktop
Select New / Shortcut
Enter in "shutdown -s -t 00" - no quotes
Press the Next button
For the name, enter in anything you like. I just use shutdown. Click on the Finish button.
For a reboot, enter "shutdown -r -t 00"
Shutdown [{-l|-s|-r|-a}] [-f] [-m [\\ComputerName]] [-t xx] [-c "message"] [-d[u][p]:xx:yy]
Parameters
-l - Logs off the current user, this is also the defualt. -m ComputerName takes precedence.
-s - Shuts down the local computer.
-r - Reboots after shutdown.
-a - Aborts shutdown. Ignores other parameters, except -l and ComputerName. You can only use -a during the time-out period.
-f - Forces running applications to close.
-m [\\ComputerName] - Specifies the computer that you want to shut down.
-t xx - Sets the timer for system shutdown in xx seconds. The default is 20 seconds.
-c "message" - Specifies a message to be displayed in the Message area of the System Shutdown window. You can use a maximum of 127 characters. You must enclose the message in quotation marks.
mizzfit
05-20-2008, 07:51 AM
thanks for the reply, i did have that but obviosuly i didnt post that. It executes the command properly and doesnt run the second command.
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.
C:\Documents and Settings\rrood>cd Desktop
C:\Documents and Settings\rrood\Desktop>chkd.bat
C:\Documents and Settings\rrood\Desktop>echo y | chkdsk c: /f /r /x && shutd
own -r -t 00
The type of the file system is NTFS.
Cannot lock current drive.
Chkdsk cannot run because the volume is in use by another
process. Would you like to schedule this volume to be
checked the next time the system restarts? (Y/N)
This volume will be checked the next time the system restarts.
C:\Documents and Settings\rrood\Desktop>
and then it just doesnt restart.
EzyStvy
05-20-2008, 07:59 AM
Post the entire batch file:)
Does it start with CMD to get you to a cmd promt?
vBulletin® v3.7.0, Copyright ©2000-2008, Jelsoft Enterprises Ltd.