Solved

Creating a script to delete a file

Posted on 2006-11-06
5
132 Views
Last Modified: 2010-04-13
We have a Win2K AD. Currently there is a logon.bat file which gets pulled down every time a user logs on. It basically automatically maps some network drives. I wish to delete a certain file from the machine. I'd like to do this by group policy, rather than going round all the machines manually and doing it! Would this line be sufficient?

del c:\program files\folder\folder2\file.exe

What if the user has insufficient privileges to delete that file?
0
Comment
Question by:Stringent
[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
  • 2
5 Comments
 
LVL 12

Expert Comment

by:RubenvdLinden
ID: 17881855
Try this simple batch script:

@echo off
del "c:\program files\folder\folder2\file.exe"
if not errorlevel 1 goto end
echo "Failed" > \\SERVER\PUBSHARE\%computername%.txt
:end

Replace \\SERVER\PUBSHARE with a public share on one of your servers.
All computers where the file could not be deleted will be stored as text files on this share.
0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 17882152
If the user does not have sufficient priveleges it is easy to five them some for this purpose or you can run the script as a startup script assigned to the computers's OU rather than a login script assinged to the user   which then runs as the computer a/c and therefore should have full access.

Otherise in Group policy drill down under computer config. and you can set file permissions for a particualr file or directory.  If it exists when the computer policies run it will give acccess the ntfs permission you define access to it.  
0
 
LVL 43

Accepted Solution

by:
Steve Knight earned 100 total points
ID: 17882169
Here is the bit in GPO:

Computer Configuration/Windows Settings/Security Settings/File System
• Click Add File, in Add a file or folder, click the file or folder that you want to change, and then click OK.

See here for info.

http://technet2.microsoft.com/WindowsServer/en/library/1687ef1d-b382-49c7-b184-a4cc888be5251033.mspx?mfr=true
 
0
 

Author Comment

by:Stringent
ID: 17887622
Where would I stick the batch script, and how would I get it to load on logon?
0
 
LVL 12

Expert Comment

by:RubenvdLinden
ID: 18084562
You can simply start the batch file at the end of your logon.bat.
0

Featured Post

Ready to get started with anonymous questions?

It's easy! Check out this step-by-step guide for asking an anonymous question on Experts Exchange.

Question has a verified solution.

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

NTFS file system has been developed by Microsoft that is widely used by Windows NT operating system and its advanced versions. It is the mostly used over FAT file system as it provides superior features like reliability, security, storage, efficienc…
OnPage enhanced its integration with ConnectWise Manage to offer incident responders more control over the ticket and Incident Resolution Lifecycle.
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

630 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