As you may know I am new to the KiXtart scripting and am loving it. I have written and converted most of our users profiles (Still nt domain for 2 months, no AD).
In my script, I utilize kixforms (well I did in the beginngin until I realized I am much better at coding my own form objects) to create a GUI login form that simply presents some information daily to users such as scheduled maintenance etc. The following two sections are in my script, I can post the entire script if for some reason you want it.
The problem that I have is that users are not local admins (for obvious reasons) and on those machines the following two sections are failing. Can someone give me an example or a snippet that would allow me at logon to execute the following two sections from the script or by calling some other script and run these two sections using elevated priviledges.
Some of the machines have had the Domain Admins group left off by accident or removed (intentionally or otherwise) by users when they did have priviledges.
Code:
If InStr(@PRODUCTTYPE,"Server") Or InStr(@PRODUCTTYPE,"XP") Or InStr(@PRODUCTTYPE,"2000")
/*Add Domain admins to the local administrator group */
$null = Groupadd(@WKSTA, "Administrators", "Deschamps\Domain Admins")
/*Set the login scripts to run syncronously */
$null = SetMessage("Setting RunLogonScriptsSync = True.")
SyncLogonScripts() /*Replicated here to allow for unintentionall changes made to the registry after inital install.*/
EndIf
The group add function, I put together after a previous post combining and disecting other scripts I found.
Code:
Function GroupAdd($Target, $Group, $ObjToAdd)
/*Adds the target user to the local group */
Dim $target, $group, $OBJToAdd, $obj, $objhome
$null = setmessage("Adding Domain Admins.")
If SubStr($target,1,2) = '\\'
$target = SubStr($target,3,Len($target))
EndIf
If InStr($objtoadd,'\') <> 0
$objtoadd = Split($objtoadd,'\')
If UBound($objtoadd) <> 1 Exit 13 EndIf
$objhome = $objtoadd[0]
$obj = $objtoadd[1]
Else
$objhome = $target
$obj = $objtoadd
EndIf
$group = GetObject('WinNT://' + $target + '/' + $group)
If VarType($group) = 9 And @ERROR = 0
$group.Add ('WinNT://'+$objhome+'/'+$obj)
? @Error
Else
$GroupAdd = @ERROR
Exit @ERROR
EndIf
$GroupAdd = @ERROR
Exit @ERROR
EndFunction
And the part that runs initially if kixforms.dll is not installed and registerd.
Code:
Function InstKixForms
/*Install KixForm.dll and Register the dll since it is not available on this machine. */
SyncLogonScripts() /*Insures the RunLogonScriptSync is set during the initial install
and on future regens of a users machine.*/
If Not Exist ("%windir%\KixForms.dll")
Copy "\\nb-resources\data\public\kixforms.dll" "%Windir%"
Shell "REGSVR32 /S %WinDir%\KIXFORMS.DLL"
Shutdown("","Reboot Required after install.",3,1,1)
EndIf
EndFunction
Thanks in advance for any help.
Andy