Thursday, June 8, 2017

windows - Run a scheduled task when a disk volume is attached

I have this Windows 10 virtual environment where frequently I need to attach raw disk volumes to the virtual machine, then I need to run diskpart on it to initialize it. I think I need Window Task Scheduler to do the job. So here are the steps:



  1. The volume is attached by the VM managing tool.

  2. The scheduled task founds that the volume is attached, then run the diskpart script.


The diskpart part is easy, but how do I know if a volume is attached? I think it involves in using system events as task triggers, but what events should I look into?


Diskpart Logic


select disk 1
attribute disk clear readonly
online disk
convert mbr
create part primary
format quick
assign letter d:
exit

No comments:

Post a Comment

hard drive - Leaving bad sectors in unformatted partition?

Laptop was acting really weird, and copy and seek times were really slow, so I decided to scan the hard drive surface. I have a couple hundr...