Home > Uncategorized > Script to rescan your disks via DiskPart.

Script to rescan your disks via DiskPart.

If you own a SATA HDD dock and tend to switch HDDs around or power them off when not in use.  Depending on your SATA controller on your motherboard it may or may not automatically detect a HDD when you switch your SATA HDD dock back on without rebooting the machine.  Windows 7 allows for this plug and play capability of SATA controllers, but some controllers don’t play nice.  I find myself having to open the Computer Management Console and navigating to the Disk Management to rescan the disks so they can be accessible.  After a year+ of this I finally decided to not be lazy and just write a script to do this via DISKPART.  I essentially used the diskpart /s argument to pass in the diskpart RESCAN command.

RescanDisks.bat:
@ECHO OFF
TITLE Diskpart – Rescan DISKS
Diskpart /s RescanDisks.txt
ECHO.  Rescanning HDDs…

RescanDisks.txt:
RESCAN
EXIT

The EXIT may not be necessary, but it shouldn’t hurt.  Both files should be in the same directory.

I haven’t been able to blog much since I’m working at a full-time gig as a build engineer/developer/tester and also developing additional features for the Inventory Tool for InterConnection in Seattle.

Categories: Uncategorized
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.