Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Creating a script to delete a file

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

Enroll in September's Course of the Month

This month’s featured course covers 16 hours of training in installation, management, and deployment of VMware vSphere virtualization environments. It's free for Premium Members, Team Accounts, and Qualified Experts!

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…
On September 18, Experts Exchange launched the first installment of the Help Bell, a new feature for Premium Members, Team Accounts, and Qualified Experts. The Help Bell will serve as an additional tool to help teams increase question visibility.
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

705 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