Advertisement
Guest User

LogonScript

a guest
Nov 10th, 2010
254
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 2.77 KB | None | 0 0
  1. Option Explicit
  2.  
  3. ' Declare Variables
  4. Dim Answer
  5. Dim ObjNetwork, objUser
  6. Dim strUserName
  7. Dim WshShell, objFSO, strUserProfile, source, destination
  8. Dim objSysInfo, strUserPath
  9. Dim strGroup, strGroupName, objGroup, strGroupPath
  10.  
  11.  
  12. ' Set Variables for Functions
  13. Set objNetwork = CreateObject("WScript.Network")
  14. Set WshShell = WScript.CreateObject("WScript.Shell")
  15. Set objFSO = CreateObject("Scripting.FileSystemObject")
  16. Set objSysInfo = CreateObject("ADSystemInfo")
  17. strUserPath = "LDAP://" & objSysInfo.UserName
  18. Set objUser = GetObject(strUserPath)
  19. Set objSysInfo = CreateObject("ADSystemInfo")
  20.  
  21. ' Set Variables for User Information
  22. strUserName = objNetwork.UserName
  23. Answer=msgbox(strUserName)
  24. strUserProfile = wshShell.ExpandEnvironmentStrings("%USERPROFILE%")
  25.  
  26. 'Call Functions
  27. RemoveDrives()
  28. CreateShortcut()
  29. GetGroup()
  30.  
  31. Function GetGroup()
  32.     For Each strGroup in objUser.MemberOf
  33.         strGroupPath = "LDAP://" & strGroup
  34.         Set objGroup = GetObject(strGroupPath)
  35.         strGroupName = objGroup.CN
  36.  
  37.         Select Case strGroupName
  38.             Case "NoAccess"
  39.                 objNetwork.MapNetworkDrive "t:", "\\DC2\VLFCU Policies"
  40.                 Exit Function
  41.        
  42.             Case "Card Dept"
  43.                 objNetwork.MapNetworkDrive "m:", "\\dc2\Data\Shared\Card Department\Apps"
  44.                 GeneralMapDrives()
  45.  
  46.             Case "Cardsource"
  47.                 objNetwork.MapNetworkDrive "m:", "\\dc2\Data\Shared\Card Department\Apps"
  48.                 GeneralMapDrives()
  49.         End Select
  50.     Next
  51.     GeneralMapDrives()
  52.    
  53. End Function
  54.  
  55.  
  56. Function RemoveDrives()
  57.     Answer=MsgBox("Remove Drives Function Called")
  58.     On Error Resume Next
  59.     '_____/Drives mapped for all users (deletes, then re-maps)\_____
  60.     objNetwork.RemoveNetworkDrive "f:"
  61.     objNetwork.RemoveNetworkDrive "g:"
  62.     objNetwork.RemoveNetworkDrive "h:"
  63.     objNetwork.RemoveNetworkDrive "j:"
  64.     objNetwork.RemoveNetworkDrive "m:"
  65.     objNetwork.RemoveNetworkDrive "q:"
  66.     objNetwork.RemoveNetworkDrive "u:"
  67.     objNetwork.RemoveNetworkDrive "r:"
  68.     objNetwork.RemoveNetworkDrive "t:"
  69.     Answer2=MsgBox("Remove Drives Function Complete")
  70. End Function
  71.  
  72. Function GeneralMapDrives()
  73.     Answer=MsgBox("General Map Drives Function Called")
  74.     On Error Resume Next
  75.     objNetwork.MapNetworkDrive "f:", "\\dc2\Data\Apps"
  76.     objNetwork.MapNetworkDrive "g:", "\\dc2\Data"
  77.     objNetwork.MapNetworkDrive "h:", "\\dc2\users\" & strUserName
  78.     objNetwork.MapNetworkDrive "j:", "\\dc2\Data\apps\shrclndr"
  79.     objNetwork.MapNetworkDrive "u:", "\\dc2\Users\"
  80.     objNetwork.MapNetworkDrive "r:", "\\edoc\doclogic\edi\cua197\reports"
  81.     Answer2=MsgBox("General Map Drives Function Complete")
  82. End Function
  83.  
  84.  
  85.  
  86. Function CreateShortCut()
  87.     source="\\vlfcu.local\sysvol\vlfcu.local\scripts\vlc"
  88.     destination= strUserProfile & "\Desktop"
  89.     Answer=Msgbox(destination)
  90.     If objFSO.FolderExists(source) Then
  91.     objFSO.CopyFolder source, destination
  92.     End If
  93. End Function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement