Link to home
Start Free TrialLog in
Avatar of detox1978
detox1978Flag for United Kingdom of Great Britain and Northern Ireland

asked on

VBScript: If user is member of HR-users copy file to desktop

Hi All,

I want to copy a shortcut to all users desktop who are a member of the AD group 'HR-users'.  Ideally i'd like to run this at logon.


Any sugestions are welcome
Avatar of merowinger
merowinger
Flag of Germany image

maybe the following?
Set objUser = GetObject("ldap://cn=testuser,ou=sales,dc=mydomain,dc=com")
Set objGroup = GetObject("ldap://cn=testgroup,ou=admin,dc=mydomain,dc=com")
 
If objGroup.IsMember(objUser.AdsPath) Then
   set objWSHShell = CreateObject("WScript.Shell")
 
   strShortcutName = "Finance Department Public Folder"
   strShortcutPath = "\\atl-finance-01\public"
 
   Set objShortcut = objWSHShell.CreateShortcut (strNetHood & "\" & strShortcutName & ".lnk")
   objShortcut.TargetPath = strShortcutPath
   objShortcut.Save
End If

Open in new window

Avatar of detox1978

ASKER

I need the script to be generic so that it will pick up the user name / OU automatically

Set objUser = GetObject("ldap://cn=testuser,ou=sales,dc=mydomain,dc=com")
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