Solved

Creating a script to delete a file

Posted on 2006-11-06
5
127 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
  • 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

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
removing broke domain controller...then upgrading to MS Win 2K12 6 393
Repair old Windows 2000 boot 15 208
Screen Mirroring 7 53
how to run this deletion request 4 10
Lotus Notes – formerly IBM Notes – is an email client application, while IBM Domino (earlier Lotus Domino) is an email server. The client possesses a set of features that are even more advanced as compared to that of Outlook. Likewise, IBM Domino is…
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…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

911 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now