RE: Deleting FIles
- From: Tesdall <Tesdall@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 27 Sep 2007 13:24:01 -0700
"a" wrote:
=?Utf-8?B?VGVzZGFsbA==?= <Tesdall@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in
news:FC58E8A0-BBEF-4F5B-B276-D0968163103A@xxxxxxxxxxxxx:
"a" wrote:
=?Utf-8?B?VGVzZGFsbA==?= <Tesdall@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in
news:A3A16BFD-3976-4A3F-9BD8-F315905CE7BC@xxxxxxxxxxxxx:
"Tesdall" wrote:attrib -h c:\TrackitAudit.id
I have a very simple script :
1>>\\10.65.0.11\report\%ComputerName%.txt 2>>&1
del c:\TrackitAudit.id 1>>\\10.65.0.11\report\%ComputerName%.txt
2>>&1 echo %date% %time% 1>>\\10.65.0.11\report\%ComputerName%.txt
If you can't tell, it will unhide the file, then delete it, then
report the time when it was last run.
It however, does not run. I have this batch file setup to run in a
GPO for the whole domain. It however has not run on anyones
machine, it is setup and ready to go. By that i mean that the
policy is set as active and and i moved it to the server
\\server\sysvol\deletetrackit.bat for easy of access. If i
manually run the file it works.
If i do a gpresult /v i get the following :
Startup Scripts
---------------
GPO: New Group Policy Object
Name: deletetrackit.bat
Parameters:
LastExecuted: 5:59:52 PM
GPO: Delete Trackit
Name: \\W2000srv2\SYSVOL\deletetrackit.bat
Parameters:
LastExecuted: 5:59:56 PM
however, the file is still there.
You should be able to combine the first two lines by using the /AH
parameter on the DEL command - this should delete a hidden file
without you needing to do the ATTRIB to remove the hidden attribute
first.
When the script runs, who is it running as (the current user,
perhaps)? For the script to work, this user will need write
permissions to
\\10.65.0.11\report\%ComputerName%.txt
(as well as to c:\TrackitAudit.id, of course)
The default permissions often deny write access to anything in the
root of C:\ for non-admin users.
What happens if the user runs the script manually instead of you?
What happens if you remove the parts that log to %ComputerName%.txt?
Am I understanding correctly that the redirection of STDERR ( 2>>&1 )
makes it go to the same place as STDOUT, and since this is redirected
to the %Computername%.txt file, it goes there? I haven't used that
before.
If i understand this correctly im running this as a startup script not
a login script which then runs the script as local admin which should
have no problem reaching C:\ .
If a normal user runs the script it says (in the log) that the file
can not be found (even though im looking right at it) however, since i
have admin rights, that if i run it then it works fine.
The 1>>\\w2000srv2\report\%ComputerName%.txt 2>>&1 part of the script
does the following, it checks to see if there is a log.txt file for
that computername and if there is not one it makes one, if there is
one it adds more lines to it. The computername part of the code is
just pretty much for netbios labeling so it would make a test.txt if
the computer was named test.
I think that it actually runs as the SYSTEM account, not the
ADMINISTRATOR account. SYSTEM would have no access to the remote log
file (just like the regular user may have no access to it).
Try this as you, just to show you what may be happening:
VER (this should work)
VER >>C:\TEST (this should also work, writing result to C:\TEST)
VER >>Q:\TEST (where Q: does not exist - this will fail)
You are correct i was thinking the local system admin however its just local
system account. I may just have to make the file del -h c:\trackitaudit.id
and thats it.
.
- References:
- RE: Deleting FIles
- From: a
- RE: Deleting FIles
- From: Tesdall
- RE: Deleting FIles
- From: a
- RE: Deleting FIles
- Prev by Date: how to create unicode folders and filenames
- Next by Date: Re: Recording AD Logons to SQL Database
- Previous by thread: RE: Deleting FIles
- Next by thread: Starting hosted application on startup
- Index(es):
Relevant Pages
|