PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Forums Hébergement > Forum Hébergement serveur > ms.win.server.scripting > Deleting FIles
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
Deleting FIles

Réponse
 
LinkBack Outils de la discussion
Vieux 25/09/2007, 18h42   #1
Tesdall
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Deleting FIles

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.

  Réponse avec citation
Vieux 25/09/2007, 19h04   #2
Tesdall
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut RE: Deleting FIles



"Tesdall" wrote:

> 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.
>



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.
  Réponse avec citation
Vieux 26/09/2007, 02h12   #3
a
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut RE: Deleting FIles

=?Utf-8?B?VGVzZGFsbA==?= <Tesdall@discussions.microsoft.com> wrote in
news:A3A16BFD-3976-4A3F-9BD8-F315905CE7BC@microsoft.com:

> "Tesdall" wrote:
>
>> 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.
>>

>
>
> 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.

  Réponse avec citation
Vieux 26/09/2007, 12h56   #4
Tesdall
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut RE: Deleting FIles



"a" wrote:

> =?Utf-8?B?VGVzZGFsbA==?= <Tesdall@discussions.microsoft.com> wrote in
> news:A3A16BFD-3976-4A3F-9BD8-F315905CE7BC@microsoft.com:
>
> > "Tesdall" wrote:
> >
> >> 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.
> >>

> >
> >
> > 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.
  Réponse avec citation
Vieux 26/09/2007, 13h04   #5
a
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut RE: Deleting FIles

=?Utf-8?B?VGVzZGFsbA==?= <Tesdall@discussions.microsoft.com> wrote in
news:FC58E8A0-BBEF-4F5B-B276-D0968163103A@microsoft.com:

> "a" wrote:
>
>> =?Utf-8?B?VGVzZGFsbA==?= <Tesdall@discussions.microsoft.com> wrote in
>> news:A3A16BFD-3976-4A3F-9BD8-F315905CE7BC@microsoft.com:
>>
>> > "Tesdall" wrote:
>> >
>> >> 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.
>> >>
>> >
>> >
>> > 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)
  Réponse avec citation
Vieux 27/09/2007, 21h24   #6
Tesdall
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut RE: Deleting FIles

"a" wrote:
> =?Utf-8?B?VGVzZGFsbA==?= <Tesdall@discussions.microsoft.com> wrote in
> news:FC58E8A0-BBEF-4F5B-B276-D0968163103A@microsoft.com:
>
> > "a" wrote:
> >
> >> =?Utf-8?B?VGVzZGFsbA==?= <Tesdall@discussions.microsoft.com> wrote in
> >> news:A3A16BFD-3976-4A3F-9BD8-F315905CE7BC@microsoft.com:
> >>
> >> > "Tesdall" wrote:
> >> >
> >> >> 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.
> >> >>
> >> >
> >> >
> >> > 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.
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 15h58.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,19536 seconds with 14 queries