Solved

deleting flles over a network using a batch file

Posted on 2009-07-07
2
305 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 our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
question about windows batch/script 3 70
cmd.exe will not close when running .bat file to perform FTP upload 18 129
WMIC Command LIne 5 56
Remote start and stop of service 3 38
If like me you are one who spends a lot of time working and scripting with cmd.exe, sometimes it is handy to be able to quickly view a calendar for a given month and year. This script will quickly do just that!  Save the code posted below to a .bat …
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…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
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…

685 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