
Login script problem - Trying to assign shortcuts via group ownership
Hello.
I'm not your die hard coder but managed to piece together the following
script to add shortcuts to the desktop based on group membership. The
problem I am now having is trying to exclude the default groups i.e. Domain
Admins, Domain Users etc.
I have tried to add an if statement but failed dismally and I kept getting
an invalid Next error. Any pointers gratefully recieved
'
' Set a loop to pick up the users groups
'
Dim Domain,UserObj, Group, GroupObj, UserName, nUser,wsh, sArray
'Now give them their initial values.....
Set wsh = WScript.CreateObject("Wscript.Shell")
Set nUser = WScript.CreateObject("Wscript.Network")
Domain = nUser.UserDomain
UserName = nUser.UserName
'Now get the current user name and domain from ADS....
Set UserObj = GetObject("WinNT://" & Domain & "/" & UserName)
'Go through each group, executing the .vbs file for each one......
On Error Resume Next
For Each GroupObj in UserObj.Groups
'The next two lines strip the spaces from the Group in question
' because the script name cannot have spaces in it
sArray= Split(GroupObj.name)
sJoin = Join(sArray,"")
'
'This code adds shotcuts to the desktop
'
Set Shell = CreateObject("WScript.Shell")
DesktopPath = Shell.SpecialFolders("Desktop")
Set link = Shell.CreateShortcut(DesktopPath & "\" & sjoin & ".lnk")
link.Arguments = "1 2 3"
link.Description = "monitor shortcut"
link.HotKey = "CTRL+ALT+SHIFT+X"
'link.IconLocation = "app.exe,1"
link.TargetPath = "\\monitor\jim" & sjoin
link.WindowStyle = 3
link.WorkingDirectory = "\\monitor\jim" & sjoin
link.Save
Next
Regards
Jim Florence