Writing a batch file in windows 7 to rescan disk

endoftheline2

Junior Member
Sep 17, 2007
23
0
0
I'm looking for a command that I can put in a batch file that will automatically "Rescan Disks"

See screenshot: <a target=_blank class=ftalternatingbarlinklarge href="http:// <a target=_blank class=ftalternatingbarlinklarge href="http://img297.imageshack.us/img297/8277/rescandisks.jpg">http://img297.imageshack.u...7/8277/rescandisks.jpg</a>">http://img297.imageshack.us/img297/8277/rescandisks.jpg</a>
Basically I have a drive connected via ESATA and it only comes on sometimes, unless I rescan disks and then it always turns on.

So I am trying to make a batch file with a command to rescan the disks, that I can then set to run using the windows scheduled tasks, at a certain time, so the computer will awake from sleep and then rescans the disks automatically, and then My backup will be able to run.
 

dfnkt

Senior member
May 3, 2006
434
0
76
Looks like MSDN refers to the diskpart.exe tool, If not present on your computer, find it on your vista CD and place it in system32 (or wherever you want, just somewhere out of the way), should be able to make the bat/cmd file say

@ECHO OFF
%WINDIR%\System32\diskpart.exe rescan

Please refer to this technet article for a full list of command line options for diskpart.exe and as always you can do %WINDIR%\System32\diskpart.exe /? and it should display it's commands. Also please note that if you place the executable in a directory path that contains spaces you will need to quote the explicit path in the batch file.

IE: "%WINDIR%\Windows Tools\diskpart.exe" rescan