Link to home
Start Free TrialLog in
Avatar of philanderson888
philanderson888

asked on

Script to delete VHD files in a classroom

Hi

I have a classroom which I do not wish to image but just delete all virtual hard drives throughout - I have a server and all clients are joined to its domain.  Clients are named Cli01 through Cli18 and are accessbile through the admin share \\Cli01\C$ etc from that server.

How do I write a script which cycles through all 18 machines and deletes every VHD (Virtual Hard Drive) file from the PC please?  I would prefer a regular batch file but powershell is fine if a regular BAT file cannot do this task.

I look forward to hearing from you.

Server OS is Server 2003
Client OS is XP SP3

Philip
Avatar of getzjd
getzjd
Flag of United States of America image

Are the VHD's all stored in a standardized location on each PC ?
Avatar of philanderson888
philanderson888

ASKER

No the VHDs are in various locations on the computers as the students install them themselves.
I would make it a classroom policy to standardize the location of the vhd's.  This keeps things organized and teaches the kids to use structure when doing things.  :-)

Unfortunately, this is above my head in terms of programming ability...   However, this is about all I can come up with

http://social.technet.microsoft.com/Forums/en/ITCG/thread/68af9e9c-565f-4b54-941a-c8369600ad03

http://www.bluemoonpcrepair.com/wp/?p=128

.http://www.appdeploy.com/messageboards/tm.asp?m=20594  

http://www.appdeploy.com/messageboards/printable.asp?m=20368
ASKER CERTIFIED SOLUTION
Avatar of GundogTrainer
GundogTrainer

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi

Thanks for both replies!

On the easy street, del \\Cli01\C$\*.vhd /s /q works fine and that is the solution I would choose.

All the machines are visible so I do not need to verify if they are on or not; I can see.

Thank you for your help; just to be fair and thorough though before I award points I'll just check through the other solutions offered by getzjd.

Phil
Good ole batch scripts!  I never give them the credit they deserve.  I am always focused on VBS which makes it 100x tougher  :-)
Hi

With respect to getzjd there was some useful stuff in there which may come in handy for me in the future and I will keep in mind.  Thanks for your input.

However if the batch file does it, and I did specify 'I would prefer a regular batch file' then for simplicity's sake that wins, I hope you understand that so thanks to 'GundogTrainer'!

Have a nice evening!  And thanks for your help, both of you!!!

Philip
Perfect!  Simplicity itself!