Admin user in Logon script 
Author Message
 Admin user in Logon script

Hello

Im using WSH for my logon script in our company. I need to delete and write
to registy because some globaly changes must be done. If im logging as
admin, everything works fine, but as user privilege, script dont work.
So, how can I promote user to admin for the logon time, or trick, how can i
start program with admin privileges.
I think KIX had same solution, but I can not find it...

Thanks..

Tomaz Kralj, MCP
RTV Slovenija



Sun, 24 Nov 2002 03:00:00 GMT  
 Admin user in Logon script
One posible trick would be to add the user to the admin group of the machine
while the script is running and then the last thing to do would be to remove
them again.  But, this would require that you know an admin and password of
that machine.  You could either use ADSi, you'll have to install if it's not
already - which I would suggest - or dump out to a command prompt and use a
net command, but you'd have to search for help on that method.

'Local Object Vars
dim strUsrPath, adsGrp, wshNet, dso, adsCpu
'Get the network object to get the computer name, users domain, and users
name
set wshNet = CreateObject("WScript.Network")
'bind to the namespace
set dso = GetObject("WinNT:")
'Bind to the computer using an admins credentials
'This will allow you to bind to the administrators group to add the user
'without the user needing to be an administrator
'the parms are 'OpenDSObject(ObjectPath, Admins ID, Admin Pswd, Reserved)'
'the admin ID needs to be in the form 'Domain\ID'
set adsCPU = dso.OpenDSObject("WinNT://" & wshNet.ComputerName, strAdminID,
strAdminPswd, 1)
'Build the adsPath to the current users account
strUsrPath = "WinNT://" & wshNet.UserDomain & "/" & wshNet.UserName
'Bind to the Administrators of the local cpu using the credentials of an
admin
set adsGrp = adsCPU.GetObject("Group", "Administrators")
'add the user to the administrators group
adsGrp.Add adsUsr.AdsPath
......
'Do your script to make changes
......
'Remove the user from the administrators group
adsGrp.Remove adsUsr.AdsPath
'Clear out objects
set adsGrp = nothing


Quote:
> Hello

> Im using WSH for my logon script in our company. I need to delete and
write
> to registy because some globaly changes must be done. If im logging as
> admin, everything works fine, but as user privilege, script dont work.
> So, how can I promote user to admin for the logon time, or trick, how can
i
> start program with admin privileges.
> I think KIX had same solution, but I can not find it...

> Thanks..

> Tomaz Kralj, MCP
> RTV Slovenija




Tue, 26 Nov 2002 03:00:00 GMT  
 Admin user in Logon script
Maybe use Su.exe from the NT resource Kit ?


Quote:
> One posible trick would be to add the user to the admin group of the
machine
> while the script is running and then the last thing to do would be to
remove
> them again.  But, this would require that you know an admin and password
of
> that machine.  You could either use ADSi, you'll have to install if it's
not
> already - which I would suggest - or dump out to a command prompt and use
a
> net command, but you'd have to search for help on that method.

> 'Local Object Vars
> dim strUsrPath, adsGrp, wshNet, dso, adsCpu
> 'Get the network object to get the computer name, users domain, and users
> name
> set wshNet = CreateObject("WScript.Network")
> 'bind to the namespace
> set dso = GetObject("WinNT:")
> 'Bind to the computer using an admins credentials
> 'This will allow you to bind to the administrators group to add the user
> 'without the user needing to be an administrator
> 'the parms are 'OpenDSObject(ObjectPath, Admins ID, Admin Pswd, Reserved)'
> 'the admin ID needs to be in the form 'Domain\ID'
> set adsCPU = dso.OpenDSObject("WinNT://" & wshNet.ComputerName,
strAdminID,
> strAdminPswd, 1)
> 'Build the adsPath to the current users account
> strUsrPath = "WinNT://" & wshNet.UserDomain & "/" & wshNet.UserName
> 'Bind to the Administrators of the local cpu using the credentials of an
> admin
> set adsGrp = adsCPU.GetObject("Group", "Administrators")
> 'add the user to the administrators group
> adsGrp.Add adsUsr.AdsPath
> ......
> 'Do your script to make changes
> ......
> 'Remove the user from the administrators group
> adsGrp.Remove adsUsr.AdsPath
> 'Clear out objects
> set adsGrp = nothing



> > Hello

> > Im using WSH for my logon script in our company. I need to delete and
> write
> > to registy because some globaly changes must be done. If im logging as
> > admin, everything works fine, but as user privilege, script dont work.
> > So, how can I promote user to admin for the logon time, or trick, how
can
> i
> > start program with admin privileges.
> > I think KIX had same solution, but I can not find it...

> > Thanks..

> > Tomaz Kralj, MCP
> > RTV Slovenija




Wed, 27 Nov 2002 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Script to Change Local Admin Users to Power Users

2. Adding non-admin users to local admin group

3. script to run as an admin user account

4. Admin privileges for creating script for users

5. Multi user Logon script

6. User's Logon Script

7. Detecting Win98 User In Logon Script

8. How can I get logon server name and IP address from logon script using wsh

9. Logon user with out logon screen

10. logon.exe script.vbs in profile (logon script)

11. Retrieving IP address (in a VBScript logon script for Win9x users)

12. adding a user DSN connection to MS SQL server 2000 using AD GPO logon scripts

 

 
Powered by phpBB® Forum Software