Solved

deleting flles over a network using a batch file

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

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.

Question has a verified solution.

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

Suggested Solutions

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…
Introduction: Recently, I got a requirement to zip all files individually with batch file script in Windows OS. I don't know much about scripting, but I searched Google and found a lot of examples and websites to complete my task. Finally, I was ab…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

732 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