Question Locked

How do I create a bat that will run from flash drive

0 helpful
2 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

I am attempting to make a massive rollout that I am doing easier by creating a bat file on a flash drive that will do a defrag and scandisk on the local computer (c:\).

I have created two files:

The main bat file and text document that contains the drive information:

Here are the contents:

*****bat File*****
REM chkdsk and defrag automation for /F "eol= tokens=1 delims=( " %%i in (DrvLtr.txt) do set DrvLtr=%%i& call :dsKchk

:dsKchk If %DrvLtr% == end goto :eof chkdsk %DrvLtr% If not errorlevel 3 goto :defrag If not exist %DrvLtr%\winnt If not exist %DrvLtr%\windows If not exist %DrvLtr%\pagefile.sys goto :dskchkon

:dskchkoff
cd\
%DrvLtr%
chkdsk /f /r
goto :defrag

:dskchkon
chkdsk %DrvLtr% /f /r

:defrag
cd\
%DrvLtr% defrag %DrvLtr% -b
defrag %DrvLtr%

shutdown -r -c "Rebooting for latest updates."

:EOF

******** Text*****
c:
end

I have 1700 computers to rollout. Any suggestions on how I can get this bat to run from a flash drive and work on the local hard drive would be appreciated.

2 replies

by rob miners

Apparently you can't Autorun straight from USB it isn't supported. You will have to download and install a small utility to each PC to get it to work. This is freeware.

http://www.snapfiles.com/get/usbautorun.html

You will also need autorun.exe

http://www.brothersoft.com/downloads/autorun-exe.html

Contents of autorun.inf

[Autorun]
open=AutoRun.exe Dskchk.cmd

Files required on Flash
autorun.inf
drvltr.txt
Dskchk.cmd
AutoRun.exe

This discussion is closed to new replies.