Forum Search:
Forum.Brain-Cluster.com: Brain Cluster Technical Forum
Ultimate forum for Technical Discussions

Home » Microsoft » Windows Server » Active Directory » Delete files
Delete files [message #158991] Wed, 22 July 2009 12:16 Go to next message
Dean  is currently offline Dean
Messages: 25
Registered: July 2009
Junior Member
Hello,

I am trying to delete 1 file with my logon script. It is at the root of all
of my users' C drive. It is also a hidden file. What I am currently trying
and is not working is this:

ATTRIB - H C:\filename
DEL C:\filename

I am sure that I have permissions to run the script as I have domain admin
privs.

TIA,
Dean
Re: Delete files [message #158994 is a reply to message #158991] Wed, 22 July 2009 14:36 Go to previous messageGo to next message
rlmueller-nospam  is currently offline rlmueller-nospam  United States
Messages: 292
Registered: July 2009
Senior Member
Dean wrote:

> I am trying to delete 1 file with my logon script. It is at the root of
> all
> of my users' C drive. It is also a hidden file. What I am currently
> trying
> and is not working is this:
>
> ATTRIB - H C:\filename
> DEL C:\filename
>
> I am sure that I have permissions to run the script as I have domain admin
> privs.

I would expect that your users lack permissions to delete the file. The
logon script runs with the credentials of the user. This is a case where it
is probably better to delete the file yourself remotely. For example, you
can use WMI, as per this link:

http://www.microsoft.com/technet/scriptcenter/guide/sas_fil_ vudw.mspx

The example in the link uses strComputer = ".", which is the local computer.
To run this remotely on another computer, assign the NetBIOS name of the
computer to the variable strComputer. You need to be a member of the local
Administrators group on the machine. By default, the group "Domain Admins"
is a member of this group when the computer is joined to the domain. Also,
instead of the clause used in the link:

WHERE Extension = 'wma'

you would specify the specific file with a clause similar to:

WHERE Name = 'c:\\Scripts\\Adsi.vbs'

Note that backslashes in the path must be doubled. Once you have a script
that deletes a file on one computer, you can code a script that reads
computer names from a text file (using the FileSystemObject) and for each
computer, connects with WMI and deletes the file.

Finally, on some OS's, like Vista, not even an admin can delete (or create)
files in the root of C:, unless they use "Run as administrator". I haven't
tested, but I think the code using WMI will still work if the client is
Vista.

--
Richard Mueller
MVP Directory Services
Hilltop Lab - http://www.rlmueller.net
--
Re: Delete files [message #159000 is a reply to message #158991] Wed, 22 July 2009 15:52 Go to previous messageGo to next message
Jorge Silva  is currently offline Jorge Silva
Messages: 398
Registered: July 2009
Senior Member
Hi
Del C:\Filename.somt | Y

--
I hope that the information above helps you.
Have a Nice day.

Jorge Silva
MVP Directory Services
"Dean" <Dean@discussions.microsoft.com> wrote in message
news:763CF363-C6C9-4DAD-A6E4-F78D25418463@microsoft.com...
> Hello,
>
> I am trying to delete 1 file with my logon script. It is at the root of
> all
> of my users' C drive. It is also a hidden file. What I am currently
> trying
> and is not working is this:
>
> ATTRIB - H C:\filename
> DEL C:\filename
>
> I am sure that I have permissions to run the script as I have domain admin
> privs.
>
> TIA,
> Dean
Re: Delete files [message #159001 is a reply to message #158991] Wed, 22 July 2009 15:54 Go to previous messageGo to next message
Jorge Silva  is currently offline Jorge Silva
Messages: 398
Registered: July 2009
Senior Member
Forgot to say that you can also use /Q switch

--
I hope that the information above helps you.
Have a Nice day.

Jorge Silva
MVP Directory Services
"Dean" <Dean@discussions.microsoft.com> wrote in message
news:763CF363-C6C9-4DAD-A6E4-F78D25418463@microsoft.com...
> Hello,
>
> I am trying to delete 1 file with my logon script. It is at the root of
> all
> of my users' C drive. It is also a hidden file. What I am currently
> trying
> and is not working is this:
>
> ATTRIB - H C:\filename
> DEL C:\filename
>
> I am sure that I have permissions to run the script as I have domain admin
> privs.
>
> TIA,
> Dean
RE: Delete files [message #159008 is a reply to message #158991] Wed, 22 July 2009 16:22 Go to previous messageGo to next message
Anderson Lacruz  is currently offline Anderson Lacruz
Messages: 15
Registered: July 2009
Junior Member
Hi Dean

I think this It can help you. I attach link:
Delete file:
http://support.microsoft.com/kb/197425
http://msdn.microsoft.com/en-us/library/system.io.file.delet e.aspx
Unhide file
http://msdn.microsoft.com/en-us/library/system.io.file.setat tributes.aspx

You can combine these scripts to achieve what you want

Regards
Anderson Lacruz

"Dean" wrote:

> Hello,
>
> I am trying to delete 1 file with my logon script. It is at the root of all
> of my users' C drive. It is also a hidden file. What I am currently trying
> and is not working is this:
>
> ATTRIB - H C:\filename
> DEL C:\filename
>
> I am sure that I have permissions to run the script as I have domain admin
> privs.
>
> TIA,
> Dean
Re: Delete files [message #159040 is a reply to message #159001] Thu, 23 July 2009 07:42 Go to previous messageGo to next message
Dean  is currently offline Dean
Messages: 25
Registered: July 2009
Junior Member
Jorge,

Both of your post worked great! Thank you for the help!!

Dean

"Jorge Silva" wrote:

> Forgot to say that you can also use /Q switch
>
> --
> I hope that the information above helps you.
> Have a Nice day.
>
> Jorge Silva
> MVP Directory Services
> "Dean" <Dean@discussions.microsoft.com> wrote in message
> news:763CF363-C6C9-4DAD-A6E4-F78D25418463@microsoft.com...
> > Hello,
> >
> > I am trying to delete 1 file with my logon script. It is at the root of
> > all
> > of my users' C drive. It is also a hidden file. What I am currently
> > trying
> > and is not working is this:
> >
> > ATTRIB - H C:\filename
> > DEL C:\filename
> >
> > I am sure that I have permissions to run the script as I have domain admin
> > privs.
> >
> > TIA,
> > Dean
>
Re: Delete files [message #159045 is a reply to message #159040] Thu, 23 July 2009 09:06 Go to previous message
Jorge Silva  is currently offline Jorge Silva
Messages: 398
Registered: July 2009
Senior Member
Great :)

--
I hope that the information above helps you.
Have a Nice day.

Jorge Silva
MVP Directory Services
"Dean" <Dean@discussions.microsoft.com> wrote in message
news:FE5C7A0B-E389-4253-B982-335E41B119A1@microsoft.com...
> Jorge,
>
> Both of your post worked great! Thank you for the help!!
>
> Dean
>
> "Jorge Silva" wrote:
>
>> Forgot to say that you can also use /Q switch
>>
>> --
>> I hope that the information above helps you.
>> Have a Nice day.
>>
>> Jorge Silva
>> MVP Directory Services
>> "Dean" <Dean@discussions.microsoft.com> wrote in message
>> news:763CF363-C6C9-4DAD-A6E4-F78D25418463@microsoft.com...
>> > Hello,
>> >
>> > I am trying to delete 1 file with my logon script. It is at the root
>> > of
>> > all
>> > of my users' C drive. It is also a hidden file. What I am currently
>> > trying
>> > and is not working is this:
>> >
>> > ATTRIB - H C:\filename
>> > DEL C:\filename
>> >
>> > I am sure that I have permissions to run the script as I have domain
>> > admin
>> > privs.
>> >
>> > TIA,
>> > Dean
>>
Previous Topic:Re: Rename 2008-level domain with Exchange 2007 present
Next Topic:AD on XP/Limit Activities
Goto Forum:
  


Current Time: Fri Oct 20 03:10:04 EDT 2017

Total time taken to generate the page: 0.02670 seconds
.:: Contact :: Home ::Sitemap::.

Powered by: FUDforum 3.0.0RC2.
Copyright ©2001-2009 FUDforum Bulletin Board Software