Solved

deleting flles over a network using a batch file

Posted on 2009-07-07
2
301 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

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…
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …

911 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

23 Experts available now in Live!

Get 1:1 Help Now