Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


User Profile Login Script section in Active Directory?

Posted on 2005-05-02
Medium Priority
Last Modified: 2008-08-05
This is actually a two piece question.  One is it possible to run more than one batch file/script in the User Profile: Login Script in Active Directory, or am I limited to one script per user (in the case I already have a script set in the User Profile: Login Script)?  

Second is it possible to assign a script to a Security Group?  Reason being is I have several OUs for separate departments (which I have scripts set in the GP for each department, mostly mapped drives) but have a Security Groups for Committees/Groups that span across several of these departments.  What I would like to do is set up a script to map shortcuts to shared folders for sharing their committee/group data.  Any help is welcome.  

Last thing, I've read in order to right a script to set up a shortcut you actually have to create the shortcut first , then copy that shortcut to the location you want on their computer?  Just a quick example of what I would like to do:

Server folder share path:
D:\Committee Folders\Management Team (Managment Team is shared folder)

What I would like to to create a shortcut to Management Team and place on the members desktop.
So what I would do is create shared folder to hold shorcuts that way the shortcuts aren't located in the shared folder:

D:\Committe Folder Shortcuts\Management Team.lnk (shortcut pointing to the Management Team folder)

;Delete the mapped drive
net use "T:" /d

;Setup a temp mapped drive for shortcut copy
net use "T:" \\Server\Committtee Folder Shortcuts

;Copy the shortcut if it isn't there
If Not Exist("%Userprofile%\Desktop\Management Team.lnk")
     copy "T:\\Server\Committee Folder Shortcuts\Management Team.lnk"  "%Userprofile%\Desktop"
End IF

;Clean out mapped drive thats not needed
net use "T:" /d

Please let me know if my logic looks right or if anything looks wrong.

Question by:HAC_ITS
LVL 39

Expert Comment

ID: 13915033
that looks like it would work fine

you can get logon scripts to run other scripts - just make the last line point to another script

i have 5 different logon scripts, but only 1 printer script - 4 of the 5 logon scripts calls the printer script at the end

Kix32 works wonders for things like this

I am pretty sure that you can set up a policy which includes a logon script to selected members, but you can't directly make members of a security group run another script

i have now used up the word script, and am banned from typing it anymore


script script script

Expert Comment

ID: 13915117
WSH/VBS code works really well in Windows 2000/XP/2003 :)

I will post an example of it tomorrow.

LVL 18

Expert Comment

ID: 13917132
I always recommend using group policy for login scripts vs. doing it on the accounts in AD if you are going to implement a script on a large scale basis. Meaning if you want more than just a couple of people to run the script then using group policy reduces the amount of work involved since you don't have to one by one add the script for each user. And it is so much easier to manage this way in case there needs to be changes made, it needs to be removed, etc.

As far as mapping drives based on security groups.  You of course can't apply group policy direct to security groups. You can filter a policy so that only specific security groups will get the policy. Or you can do this in your script. I'll try to post an example of a vbs script that does this.  I map printers based on security groups using wsh/vbs and it is very simple to do.

I like using wsh and vbs and mentioned by one post above. Its a matter of preference as to what you write your scripts in.....i seem to understand vbs more and feel more comfortable using it.
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


Accepted Solution

BILJAX earned 2000 total points
ID: 13917691
'Declares variables used through-out the script

DIM UserDriveLetter
DIM drive
DIM fso
DIM message
UserDriverLetter = "U:"

'Removes previously mapped drives
On error resume next

Set oDrives = WshNetwork.EnumNetworkDrives
For i = 0 to oDrives.Count - 1 Step 2
WshNetwork.RemoveNetworkDrive oDrives.Item(i),true,true

'Maps the User's Home directory

Set WshShell = WScript.CreateObject("WScript.Shell")
Set wshNetwork = CreateObject("WScript.Network")
Set fso = CreateObject("Scripting.FileSystemObject")

wshNetwork.MapNetworkDrive "U:", "\\FILESERVER\" & wshNetwork.Username

'Maps the pre-determined user directories

wshNetwork.MapNetworkDrive "F:", "\\SERVER1\SHARE" & ""
wshNetwork.MapNetworkDrive "H:", "\\SERVER1\ANOTHERSHARE" & ""
wshNetwork.MapNetworkDrive "K:", "\\SERVER4\YETANOTHERSHARE" & ""
wshNetwork.MapNetworkDrive "V:", "\\SERVER1\VIRUSDATSHARE" & ""

'Maps Printers

wshNetwork.AddWindowsPrinterConnection "\\SERVER1\PRINTER2"
wshNetwork.AddWindowsPrinterConnection "\\SERVER2\PRINTER2"
wshNetwork.AddWindowsPrinterConnection "\\SERVER1\PRINTER1"
wshNetwork.AddWindowsPrinterConnection "\\SERVER3\PRINTER5"
wshNetwork.SetDefaultPrinter "\\SERVER1\PRINTER2"

'Runs Time Syncrhonization
WshShell.Run ("\\SERVER\NETLOGON\time.vbs")

'Calls AV update, place where Mcafee DAT files are downloaded daily.
WshShell.Run ("V:\vupdate.exe /SILENT /PROMPT /F")

'Displays Home Directory and Free Space

Sub FindSpace(drive, message)
DIM space
DIM units

space = drive.FreeSpace

if space >= 1073741824 then
 space = Round(space / 1073741824, 2)
 units = "GB"
elseif space >= 1048576 then
 space = Round(space / 1048576, 2)
 units = "MB"
elseif space >= 1024 then
 space = Round(space / 1024, 2)
 units = "KB"
end if

message = message & vbCRLF & "You have " & space & " " & units & " free." & vbCRLF

End Sub

'Displays message to the user, will only display space left if disk quota is used.

message = "User Directory Usage: " & vbCRLF

Function ShowFreeSpace(UserDriveLetter)
   Dim fso, d, s
   Set fso = CreateObject("Scripting.FileSystemObject")
   Set d = fso.GetDrive(fso.GetDriveName(UserDriveLetter))
   s = "Drive " & UCase(UserDriveLetter) & " - " 
   s = s & d.VolumeName   & "<BR>"
   s = s & "Free Space: " & FormatNumber(d.FreeSpace/1024, 0)
   s = s & " Kbytes"
   ShowFreeSpace = s
End Function

MsgBox message, , "Welcome to the Domain, " & wshNetwork.UserName

The time.vbs:

DIM fso
DIM WshShell
Set WshShell = WScript.CreateObject("WScript.Shell")
Set fso = WScript.CreateObject("Scripting.FileSystemObject")

WshShell.Run("%COMSPEC% /c net time \\\\TIMESERVER /set /y")

If you have alot of users, it's better to setup the scripts like luv2smile suggested.  However, if you only deal with alimited amout of users, you can use user profiles.



Author Comment

ID: 13920495
I've just been using batch files (.bat) for scripts so using WSH/VBS would be new to me.  Could you point me in the direction for starting to go that route BILJAX or anyone else.


Expert Comment

ID: 13920796

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A common practice in small networks is making file sharing easy which works extremely well when intra-network security is not an issue. In essence, everyone, that is "Everyone", is given access to all of the shared files - often the entire C: drive …
Measuring Server's processing rate with a simple powershell command. The differences in processing rate also was recorded in different use-cases, when a server in free and busy states.
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
How can you see what you are working on when you want to see it while you to save a copy? Add a "Save As" icon to the Quick Access Toolbar, or QAT. That way, when you save a copy of a query, form, report, or other object you are modifying, you…

571 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question