Jump to content


 


Register a free account to unlock additional features at BleepingComputer.com
Welcome to BleepingComputer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.


Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.

Photo

assistance in creating a batch file


  • Please log in to reply
7 replies to this topic

#1 tetley69

tetley69

  • Members
  • 2 posts
  • OFFLINE
  •  
  • Local time:02:34 PM

Posted 15 March 2016 - 12:27 PM

 

I would appreciate assistance in creating a batch file I can run manually that would delete all files in a certain directory across all users in our Domain.

 

Basically I have discovered that a program is downloading and storing updates on our Server in each user profile inside Terminal Services and it's just taking up unnecessary space on the hard drive. Rather then go into each user's file individually and remove the files, I was wondering if I could instead have a batch file that would remove all the files contained in the following sub-directory:

 

E:\User Shares\RedirectedFolder$\%username%\Application Data\Foxit Software\Addon\Install

 

Thank you in advance.

 



BC AdBot (Login to Remove)

 


#2 RolandJS

RolandJS

  • Members
  • 4,533 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Austin TX metro area
  • Local time:01:34 PM

Posted 15 March 2016 - 01:18 PM

If memory of my earlier days with our network guru serves me, I recall that each command line [which you sorta gave above] would have to be "hard-wired" with each username.  We used Novell back then, maybe this restriction will not apply.


"Take care of thy backups and thy restores shall take care of thee."  -- Ben Franklin revisited.

http://collegecafe.fr.yuku.com/forums/45/Computer-Technologies/

Backup, backup, backup! -- Lady Fitzgerald (w7forums)

Clone or Image often! Backup... -- RockE (WSL)


#3 SleepyDude

SleepyDude

  • Malware Response Team
  • 3,073 posts
  • ONLINE
  •  
  • Gender:Male
  • Location:Portugal
  • Local time:07:34 PM

Posted 15 March 2016 - 05:10 PM

Hi Tetley69 :welcome: to BleepingComputer

 

The E: drive exist on the server or that path is the mapped drive that the user have access?


• Please do not PM me asking for support. Post on the forums instead it will increases the chances of getting help for your problem by one of us.
• Posts in the Malware section that are not replied to within 4 days will be closed. PM me or a moderator to reactivate.
• Please post your final results, good or bad. We like to know! Thank you!

 
Proud graduate of GeekU and member of UNITE
___
Rui

 
 


#4 Wand3r3r

Wand3r3r

  • Members
  • 2,027 posts
  • OFFLINE
  •  
  • Local time:11:34 AM

Posted 15 March 2016 - 07:39 PM

echo on

del \\servername\[correct path to ]\%username%\Application Data\Foxit Software\Addon\Install\*.*

exit


Edited by Wand3r3r, 15 March 2016 - 07:40 PM.


#5 JohnnyJammer

JohnnyJammer

  • Members
  • 1,117 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:QLD Australia
  • Local time:04:34 AM

Posted 16 March 2016 - 12:58 AM

Ok this should work mate.

using DEL command tries to delete directories but it wont so you need to use RMDIR as well as DEL, remember these are hard deleted and wont end up int eh recycle bin either mate.

have this as a logins cript under UserConfig in GPO.

@ECHO OFF
::Remove files
FOR /F "tokens=1 delims=" %%X IN ('dir /b /on /s "E:\User Shares\RedirectedFolder$\%username%\Application Data\Foxit Software\Addon\Install\"') DO (
    ECHO Deleting "%%X"
    del "%%X" /F /Q    
    )
::Wait 5 seconds then remove folders
ping -n 5 127.0.0.1 > %TMP%\PING
FOR /F "tokens=1 delims=" %%X IN ('dir /b /on /s "E:\User Shares\RedirectedFolder$\%username%\Application Data\Foxit Software\Addon\Install\"') DO (
    ECHO Deleting "%%X"
    rmdir "%%X" /S /Q    
    )
exit

Edited by JohnnyJammer, 16 March 2016 - 12:59 AM.


#6 Wand3r3r

Wand3r3r

  • Members
  • 2,027 posts
  • OFFLINE
  •  
  • Local time:11:34 AM

Posted 16 March 2016 - 10:18 AM

updates will just recreate the install folder or updates will bomb because its not there which is why my one line batch only deletes all files in the install folder.

 

Your script does look prettier though :-)



#7 JohnnyJammer

JohnnyJammer

  • Members
  • 1,117 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:QLD Australia
  • Local time:04:34 AM

Posted 16 March 2016 - 04:39 PM

Yeh well i didnt think foxit reader would take up much room in the users %appdata%, also the better way would be to use NTFS permissions so the user connot write to that particular folder.

 

Anyway, that little script i did could also be used in %TMP% or any other folder really.

 

I love batchfiles LOL



#8 tetley69

tetley69
  • Topic Starter

  • Members
  • 2 posts
  • OFFLINE
  •  
  • Local time:02:34 PM

Posted 17 March 2016 - 08:09 AM

Thanks so much JohnnyJammer.  You are a batch file genius!  Thanks to all who responded.  Much appreciated.






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users