Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


How can I get a script to run under a local admin context?

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,59804
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> How can I get a script to run under a local admin context?
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 How can I get a script to run under a local admin context? - 5/4/2008 11:55:58 PM   
  midiman25

 

Posts: 3
Score: 0
Joined: 5/4/2008
Status: offline
Hi I have a script that deletes user profiles from C:\Documents and settings on a XP workstation. I have placed it as a logoff script in the local group policy.

It works fine if you log off as the local administrator but it dosn't work for anyone else.

I was thinking that if I could get the script to run as the local computers administrator each time then it would work for everyone.

Is there a way how I can do this? 

Thanks
 
 
Post #: 1
 
 RE: How can I get a script to run under a local admin c... - 5/5/2008 2:58:10 AM   
  ginolard


Posts: 1005
Score: 21
Joined: 8/10/2005
Status: offline
Off the top of my head I would say create a separate script to do it and then, using your logoff script, create a Scheduled Task using SCHTASKS.EXE to delete the profile.  I say SCHTASKS because it has the /RUN switch to execute immediately and the /RU switch to run the task under a different account (e.g. SYSTEM)

_____________________________

Author of ManagePC - http://managepc.net
AD Query Template - http://www.visualbasicscript.com/m_40609/tm.htm
Consolidated Scripting Framework - http://www.visualbasicscript.com/m_59109/tm.htm

(in reply to midiman25)
 
 
Post #: 2
 
 RE: How can I get a script to run under a local admin c... - 5/5/2008 6:05:19 AM   
  midiman25

 

Posts: 3
Score: 0
Joined: 5/4/2008
Status: offline
Thanks but the problem I have is this.

Presently we use a MS tool called DelProf to delete the profiles. We create a scheduled task and have it call DelProf every 30mins using the local administrator security context.

I want to get around this by using Group Policy on our Domain.

I want to run the script in the logoff section and have it run in the security context of the target workstations local administrator. 

Can this be done without having to create a scheduled task?

I need to say this.

1 Script run at logoff
2 Run as the this user account
3 Delete profiles 

I can get 1 and 3 to work but not 2.

Please help.  

(in reply to ginolard)
 
 
Post #: 3
 
 RE: How can I get a script to run under a local admin c... - 5/5/2008 7:12:52 AM   
  dm_4ever


Posts: 2174
Score: 32
Joined: 6/29/2006
From: Orange County, California
Status: offline
What if you make it part of the machine's logoff....if I am not mistaken, this will run under "System" which should have more than enough rights.

_____________________________

dm_4ever

My philosophy: K.I.S.S - Keep It Simple Stupid
Read Me: http://www.visualbasicscript.com/m_24727/tm.htm
Frequently Asked Stuff: http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to midiman25)
 
 
Post #: 4
 
 RE: How can I get a script to run under a local admin c... - 5/5/2008 9:15:12 PM   
  midiman25

 

Posts: 3
Score: 0
Joined: 5/4/2008
Status: offline
Do you mean part of the computer shutdown?

The problem is that our work machines are on most of the time. So unless the PC was restarted the script would never run. The machines are used by our employee base and you can get upto 100 profiles on a machine in a couple of days.

This equates to a very slow pc hence why I want to clean up the profiles asap.

Thanks

(in reply to dm_4ever)
 
 
Post #: 5
 
 RE: How can I get a script to run under a local admin c... - 5/5/2008 10:48:46 PM   
  mbouchard


Posts: 1804
Score: 12
Joined: 5/15/2003
From: USA
Status: online
Why not set the PC up to use default profiles?  That way everyone uses the same profile and you won't have to to worry about deleting extra ones.

_____________________________

Mike

For useful Scripting links see the Read Me First stickey!

Always remember Search is your friend.

(in reply to midiman25)
 
 
Post #: 6
 
 RE: How can I get a script to run under a local admin c... - 5/6/2008 11:03:06 PM   
  Rischip


Posts: 379
Score: 2
Joined: 3/26/2007
Status: offline
I would look up instsrv and srvany. Verify that you have a working script that will delete profiles when logged in under the admin account. Then install it as a service running under cscript. Have the script look for active  "Explorer" processes. If none exist then go through the delprof routine.

You cannot delete a profile you are logged into. Therefore you cannot run this as a logoff script. However as mentioned it would work as a machine shutdown/startup script. If I had to choose between those two locations I would choose startup. At shutdown there could be issues with profiles that still have hives loaded, although I believe delprof accounts for that.

Scheduled Tasks would also work, but when do you schedule it? If a user is logged in the script would have to account for that and avoid deleteing the in use profile.

_____________________________

Rischip
Author of - The Grim Linker

(in reply to mbouchard)
 
 
Post #: 7
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> How can I get a script to run under a local admin context? Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts