Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Creating a script to delete a file

Posted on 2006-11-06
5
Medium Priority
?
134 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 400 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

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…
Your business may be under attack from a silent enemy that is hard to detect. It works stealthily in the shadows to access and exploit your critical business information, sensitive confidential data and intellectual property, for commercial gain. T…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

886 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