Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsWindows Server 2003Windows 2000Windows NTSmall Business ServerVirtual ServerExchange ServerIISHost Integration ServerISA ServerSMSWSUSMOMWindows Media ServerSecurityCertification
Related Topics
SQL ServerMS WindowsMS OfficePC HardwareMore Topics ...

Windows Server Forum / Windows Server 2003 / Scripting / September 2007

Tip: Looking for answers? Try searching our database.

Deleting FIles

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Tesdall - 25 Sep 2007 18:42 GMT
I have a very simple script :

attrib -h c:\TrackitAudit.id  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.
Tesdall - 25 Sep 2007 19:04 GMT
> I have a very simple script :
>
[quoted text clipped - 10 lines]
> 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.
a - 26 Sep 2007 02:12 GMT
>> I have a very simple script :

attrib -h c:\TrackitAudit.id 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.
[quoted text clipped - 21 lines]
>
> 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.
Tesdall - 26 Sep 2007 12:56 GMT
> >> I have a very simple script :
> >>
[quoted text clipped - 45 lines]
> 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.
a - 26 Sep 2007 13:04 GMT
>> >> I have a very simple script :
>> >>
[quoted text clipped - 63 lines]
> 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)
Tesdall - 27 Sep 2007 21:24 GMT
> >> >> I have a very simple script :
> >> >>
[quoted text clipped - 72 lines]
> 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.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2010 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.