Solved

Creating a script to delete a file

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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

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…
Find out what Office 365 Transport Rules are, how they work and their limitations managing Office 365 signatures.
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

708 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

12 Experts available now in Live!

Get 1:1 Help Now