Solved

Script to delete VHD files in a classroom

Posted on 2010-11-21
8
598 Views
Last Modified: 2012-05-10
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
0
Comment
Question by:philanderson888
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
8 Comments
 
LVL 15

Expert Comment

by:getzjd
ID: 34184693
Are the VHD's all stored in a standardized location on each PC ?
0
 

Author Comment

by:philanderson888
ID: 34185689
No the VHDs are in various locations on the computers as the students install them themselves.
0
 
LVL 15

Expert Comment

by:getzjd
ID: 34185810
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
0
Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

 
LVL 8

Accepted Solution

by:
GundogTrainer earned 125 total points
ID: 34187459
If your not worried about testing if the client is online etc, you could try the really simple way:
create deleteVHD.bat with the following.

del \\Cli01\C$\*.vhd /s /q
del \\Cli02\C$\*.vhd /s /q
del \\Cli04\C$\*.vhd /s /q
del \\Cli05\C$\*.vhd /s /q
del \\Cli06\C$\*.vhd /s /q
del \\Cli07\C$\*.vhd /s /q
del \\Cli08\C$\*.vhd /s /q
del \\Cli09\C$\*.vhd /s /q
del \\Cli10\C$\*.vhd /s /q
del \\Cli11\C$\*.vhd /s /q
del \\Cli12\C$\*.vhd /s /q
del \\Cli13\C$\*.vhd /s /q
del \\Cli14\C$\*.vhd /s /q
del \\Cli15\C$\*.vhd /s /q
del \\Cli16\C$\*.vhd /s /q
del \\Cli17\C$\*.vhd /s /q
del \\Cli18\C$\*.vhd /s /q

0
 

Author Comment

by:philanderson888
ID: 34187845
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
0
 
LVL 15

Expert Comment

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

Author Comment

by:philanderson888
ID: 34198714
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
0
 

Author Closing Comment

by:philanderson888
ID: 34198717
Perfect!  Simplicity itself!
0

Featured Post

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Step by step guide to Clean and Sort your windows registry! Introduction: Always remember: A Clean registry = Better performance = Save your invaluable time In this article we're going to clear our registry manually! Yes, manually! The e…
If you have done a reformat of your hard drive and proceeded to do a successful Windows XP installation, you may notice that a choice between two operating systems when you start up the machine. Here is how to get rid of this: Click Start Clic…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question