Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Windows 2003 Server - Domain - Logon Scripts

Status
Not open for further replies.

circuitpt

Technical User
Nov 11, 2007
18
0
0
I have a windows domain built on top of windows 2003 server.

I have a default login script for my default domain policy.

Some of my users need to execute extra scripts in adition to the one defined by the policy. How can i do this?

Right now i'm simulating this behavior by placing the extra scripts in the startup folder in start-menu. But i don't think this is a very elegant solution.
Can't i define multiple login scripts for one user in Active directory?

thank you.
 
To answer your question circuitpt, Yes you can add multiple scripts to a GPO. I however prefer to write a better script in the first place. A well written login script can do just about anything you need without having to spawn off into another process which will only slow down login.

Pat, thanks for linking to my FAQ. :)

I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
Work SMARTER not HARDER. The Spider's Parlor's Admin Script Pack is a collection of Administrative scripts designed to make IT Administration easier! Save time, get more work done, get the Admin Script Pack.
 
Do a search in google for Assigning Scripts Using Group Policy
It will show you how to add additional scripts.
By the way I would leave the default domain policy alone. I never modify it, just create new ones and name them accordingly.
 
thanks :) loved the post about building scripts, I'll use some of the tips in there!

However, my question is about associating login scripts with users. I know that i can set one login script in a policy and then all the users that are in a OU that is subject to that policy will receive that login script.

However lets assume i have a set of drives I want to map in all of my users.Then i have some drives that are just for one specific user. The users has the default login script that gives him all the generic drives, can't i add a second script to run just for this user? And a third, and a fourth, etc...

Thank you.
 
i fyou read Marks script as posted above

this is the section you want
Code:
' Map drives based on login name

Select Case UserString
    Case "Username1"
         WSHNetwork.MapNetworkDrive "P:", "\\Computer or server\share",True

    Case "Username2"
         WSHNetwork.MapNetworkDrive "P:", "\\Computer or server\share",True

End Select
 
thanks, it seems i can have only one script. I had seen that part, it can be done, however that forces us to have on big complex script instead of several smaller scripts.

But it can be done like that.

Thank you :)
 
No not at all, you can use that section in your own smaller script. Call it from another script, depends on how you wish to do it.
 
This should give you an idea

Code:
Set WshNetwork = CreateObject("WScript.Network")
Set WshShell = WScript.CreateObject("WScript.Shell")
Set WshSysEnv = WshShell.Environment("Process")
Set objFSO = CreateObject("Scripting.FileSystemObject")

SysDrive = WshShell.ExpandEnvironmentStrings("%SYSTEMDRIVE%")
SysRoot = WshShell.ExpandEnvironmentStrings ("%SystemRoot%")
UserProfile = WshShell.ExpandEnvironmentStrings ("%UserProfile%")
'Automatically find the domain name
Set objDomain = getObject("LDAP://rootDse")
DomainString = objDomain.Get("dnsHostName")

'Grab the user name
UserString = WshNetwork.UserName
Set objADSysInfo = CreateObject("ADSystemInfo")
Set objCurrentUser = GetObject("LDAP://" & objADSysInfo.UserName)

'Bind to the user object to get user name and check for group memberships later
Set UserObj = GetObject("WinNT://" & DomainString & "/" & UserString)

'Grab the computer name for use in add-on code later
strComputer = WshNetwork.ComputerName
 
 'Map drives for everyone
			WshNetwork.MapNetworkDrive "L:", "\\server\share$",True
			WshNetwork.MapNetworkDrive "T:", "\\server\share$",True
			WshNetwork.MapNetworkDrive "O:", "\\server\share$",True
			
'Map drives for user
Select Case UserString
        Case "User"
			WshNetwork.MapNetworkDrive "P:", "\\server\share$",True
			WshNetwork.MapNetworkDrive "V:", "\\server\shares$",True

			WshNetwork.SetDefaultPrinter "\\server\Printer"
			WshNetwork.AddWindowsPrinterConnection "\\server\Printer"
			WshNetwork.AddWindowsPrinterConnection "\\server\Printer"

'add a shortcut to the desktop for this Users only
		Set objFSO = CreateObject("Scripting.FileSystemObject")
			strDsk = WshShell.SpecialFolders("Desktop")
		' What is the label for the shortcut?
			strshortcut = strDsk & "\My User Folder.lnk"
		If Not objFSO.FileExists(strshortcut) Then
			SET oUrlLink = WshShell.CreateShortcut(strshortcut)
		' What is the path to the shared folder?
			oUrlLink.TargetPath = "\\server\share"
			oUrlLink.Save
		End If

		Case "User2"
		do some stuff
		
End Select

'Now rename the mapped drives to a meaningful name
'===========================================================================================================
     Dim DriveArray( 2, 1 )
   DriveArray( 0, 0 ) = "L:\"
   DriveArray( 0, 1 ) = "Some nice name"
   DriveArray( 1, 0 ) = "M:\"
   DriveArray( 1, 1 ) = "Some nice name"
   DriveArray( 2, 0 ) = "N:\"
   DriveArray( 2, 1 ) = "Some nice name"

Set WshShell = CreateObject("Shell.Application")
For remap = 0 to UBound(DriveArray)

WshShell.NameSpace(DriveArray(remap,0)).Self.Name = DriveArray(remap,1)
Next
 
ok, i see. I'll manage myself with something similar to that script!

thanks :)
 
Where is this idea that you can only have one script in a GPO coming from?

Look in my FAQ and follow the instructions for how to add a script to a GPO. You can do that step multiple times on the same GPO.

I still PREFER to have just one script since it will make troubleshooting issues easier. Document your script well as I have demonstrated in my FAQ and that too will assist you in troubleshooting months or years down the road.

I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
Work SMARTER not HARDER. The Spider's Parlor's Admin Script Pack is a collection of Administrative scripts designed to make IT Administration easier! Save time, get more work done, get the Admin Script Pack.
 
it's no just one script in a group policy. I'm sorry if I'm not explaining me very well.
I'll use an example, lets say i have:
1Domain: mydomain.local
7users: mark, carla, rita, jessica, jeff, bush and jenifer
3scripts:
1st_script: maps network drives that are common to all users;
2nd_script: maps network drives that belong only to carla;
3rd_script: maps network drives that belong to jeff and bush;

-So what I wan't now is to have 1st_script run whenever any of the above users logs in.
-In addition, when carla logs in i want 2nd_script to run (but also 1st_script, they map diferent things and carla has both)
-When jeff or bush log in, just like what happens to carla (the difference is that 2nd_script is replaced by 3rd_script), i want to run 1st_script and 3rd_script.



Thanks for you time:)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top