Solved

deleting flles over a network using a batch file

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

Turn Insights Into Action

You’ve already invested in ITSM tools, chat applications, automation utilities, and more. Fortify these solutions with intelligent communications so you can drive business processes forward.

With xMatters, you'll never miss a beat.

Question has a verified solution.

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

You may have already been in the need to update a whole folder stucture using a script. Robocopy does it well and even provides a list of non-updated files in a log (if asked to). Generally those files that were locked by a user or a process by the …
AutoHotkey is an excellent, free, open source programming/scripting language for Windows. It started out as a keyboard/mouse macros product, but has expanded into a robust language. This article provides an introduction to it, with links to addition…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

691 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