Link to home
Start Free TrialLog in
Avatar of mpbsystem
mpbsystemFlag for United States of America

asked on

Logon Script for specific users on Domain Controller?

I have been trying to figure out how to program this, but I can't find enough information on how to program it correctly.  Its very basic:  I need a VBScript that will run as a login script that if a certain userID logs in it will execute this other VBScript, otherwise if any other UserID logs in it will ignore... This will be a If then Else statement with the else as ignore, but I can't figure out how to do it
Avatar of Mal Osborne
Mal Osborne
Flag of Australia image

You could just assign the login script inside a GPO, so that it only applies to certain users.
Avatar of mpbsystem

ASKER

The problem with that is I took over for another incompetent company that built this AD domain and everybody is in the same OU and not separated.  That is why I need this userID specific script.  I am afraid of changing and adding OU's to organize the AD domain because I don't want to break anything that already works!  I just want to add this script to the logon for 4 users out of 25
Note: the first poster is right...that is the preferred method.
When you create and link a NEW GPO to the OU, you can set permissions on a user or group, for that GPO to be processed or not processed.  Even though they are all in the same ou, makes no difference.

But if you are unconfortable with GPO's and policy filtering...
Then just use a batch file for execution of the script.
Example.
:1
IF %USERNAME% == Jsmith GOTO 2
IF %USERNAME% == Jjohns GOTO 2
IF %USERNAME% == Smiller GOTO 2
IF %USERNAME% == Ajackson GOTO 2
EXIT
:2
xcopy "\\server\share\yourscript.vbs" "c:\"
cscript "c:\yourscript.vbs"
del "c:\yourscript.vbs"
EXIT
OK.... I get it now.... Here is what I have in the GPO on the domain now.

Login Script: (file: resolution.bat)
Set wshShell = WScript.CreateObject ("WSCript.shell")
wshshell.run "\\home-server-1\netlogon\multires\multires.exe /800,600,32,60"
set wshshell = nothing

Logoff script: (file:highres.bat)
Set wshShell = WScript.CreateObject ("WSCript.shell")
wshshell.run "\\home-server-1\netlogon\multires\multires.exe /1024,768,32,60"
set wshshell = nothing

The logoff script doesn't apply before logging out of the computer with that one users ID
Sorry.... I have a file resolution.bat that calls lowres.vbs and another file highres.bat that calls hiresolution.vbs.  and the VBScript is in each respective VB File
Here is some more information.... If I enable to UserID to logon directly to the server to test the logon and logoff scripts work... But on the desktop it doesn't work
ASKER CERTIFIED SOLUTION
Avatar of RobSampson
RobSampson
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Great Script!!!  Used it an worked great.... Tweaked and even used at my job on a few of their servers for a similar solution
No problem, thanks for the grade.

Regards,

Rob.