Solved

deleting flles over a network using a batch file

Posted on 2009-07-07
2
298 Views
Last Modified: 2012-06-27
Hello

I have a batch file that i use to copy files to computers on our network.  the way it works is that it pings IP Addresses in a text file called ping.txt.  Those that it gets a reply from it enumerates into a yes.txt file.  I then run another batch file to copy certain files to those computers in the yes.txt file.  it works beatifully, but now i need to delete files and i dont know how to.

I need to a shorcut from the All Users\Start Menu\Programs\ folder that is called 'HelpDesk Self Service'

this is an example of the code i use to copy files... any help would be much appreciated...

** this copies the shortcut - which i now need to be removed and replaced
for /f "tokens=1" %%a in (yes.txt) do copy /y "\\192.168.12.1\shared\support\helpdesk\*.*" "\\%%a\c$\Documents and Settings\All Users\Start Menu\Programs"

**this is just an example of another line in my batch file
for /f "tokens=1" %%a in (yes.txt) do copy /y "\\192.168.12.1\shared\support\Backup\backup.bat" "\\%%a\c$\windows\system32"
0
Comment
Question by:andrewhehir
2 Comments
 
LVL 3

Accepted Solution

by:
SordSord earned 500 total points
ID: 24799788
To delete a file or files, you can replace the "copy srcfile destlocation" with "del destfile"

Using one of your samples, to remove the backup.bat files from the remote systems:
for /f "tokens=1" %%a in (yes.txt) do del "\\%%a\c$\windows\system32\backup.bat"

I'd also suggest being careful in your first sample, as you are using wildcards to copy all the files in the source directory. If you delete \\%%a\c$\Documents\*.* on the destination, you may end up deleting more files than you originally copied over.

- Eric
0
 

Author Closing Comment

by:andrewhehir
ID: 31600902
thankyou, it was easier that i thought - not exactly sure why it didnt work the first time for me, but doing helpdesk*.* did the trick!  
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

The following is a collection of cases for strange behaviour when using advanced techniques in DOS batch files. You should have some basic experience in batch "programming", as I'm assuming some knowledge and not further explain the basics. For some…
This article was inspired by a question here at Experts Exchange (http://www.experts-exchange.com/Software/Photos_Graphics/Images_and_Photos/Q_28629170.html). The requirements stated in that question are (1) reduce the file size of a large number of…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

706 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now