特别感谢水总水大人

 

 
  
  1. '映射共享和在桌面建立快捷方式  
  2. '登录(logon)脚本  
  3. 'On Error Resume Next 
  4.  
  5.  
  6.  
  7.  
  8.  
  9. Set objNetwork = CreateObject("Wscript.Network")  
  10.  
  11. WScript.echo objNetwork.UserDomain  
  12. Set objSysInfo = CreateObject("ADSystemInfo")  
  13. strUserPath = "LDAP://" & objSysInfo.UserName  
  14. Set objUser = GetObject(strUserPath)  
  15.  
  16. Dim WshShell  
  17. Dim strDesktop  
  18. Dim oShellLink1, oShellLink2, oShellLink3  
  19.  
  20. Set WshShell = WScript.CreateObject("WScript.Shell")  
  21. strDesktop = WshShell.SpecialFolders("Desktop")  
  22.     WScript.echo strUserPath  
  23.  
  24.     'strGroupPath = "LDAP://" & objUser.MemberOf  
  25.     For Each strGroup in objUser.MemberOf  
  26.     strGroupPath = "LDAP://" & strGroup  
  27.       
  28.     Set objGroup = GetObject(strGroupPath)  
  29.     strGroupName = objGroup.CN  
  30.  
  31.       
  32.      
  33.     WScript.echo strGroupName  
  34.     Select Case strGroupName  
  35.         Case "营销中心" 
  36.             objNetwork.MapNetworkDrive "X:"" \\fileserver\营销中心$" 
  37.             Set oShellLink1 = WshShell.CreateShortcut(strDesktop & "\营销中心共享组.lnk")  
  38.             oShellLink1.TargetPath = "X:\" 
  39.             oShellLink1.WindowStyle = 1  
  40.             oShellLink1.Description = "营销中心共享文件" 
  41.             oShellLink1.WorkingDirectory = "X:\" 
  42.             oShellLink1.Save  
  43.         Case "财务部" 
  44.             objNetwork.MapNetworkDrive "X:"" \\fileserver\财务部$\" 
  45.             Set oShellLink1 = WshShell.CreateShortcut(strDesktop & "\财务部共享文件组.lnk")  
  46.             oShellLink1.TargetPath = "X:\" 
  47.             oShellLink1.WindowStyle = 1  
  48.             oShellLink1.Description = "财务部共享文件" 
  49.             oShellLink1.WorkingDirectory = "X:\" 
  50.             oShellLink1.Save  
  51.         Case "管理部" 
  52.             objNetwork.MapNetworkDrive "X:"" \\fileserver\管理部$" 
  53.             Set oShellLink1 = WshShell.CreateShortcut(strDesktop & "\管理部共享文件组.lnk")  
  54.             oShellLink1.TargetPath = "X:\" 
  55.             oShellLink1.WindowStyle = 1  
  56.             oShellLink1.Description = "管理部共享文件" 
  57.             oShellLink1.WorkingDirectory = "X:\" 
  58.             oShellLink1.Save  
  59.         Case "制造部" 
  60.             objNetwork.MapNetworkDrive "X:"" \\fileserver\制造部$" 
  61.             Set oShellLink1 = WshShell.CreateShortcut(strDesktop & "\制造部共享文件组.lnk")  
  62.             oShellLink1.TargetPath = "X:\" 
  63.             oShellLink1.WindowStyle = 1  
  64.             oShellLink1.Description = "制造部共享文件" 
  65.             oShellLink1.WorkingDirectory = "X:\" 
  66.             oShellLink1.Save  
  67.         Case "研发中心" 
  68.             objNetwork.MapNetworkDrive "X:"" \\fileserver\研发中心$" 
  69.             Set oShellLink1 = WshShell.CreateShortcut(strDesktop & "\研发中心共享文件组.lnk")  
  70.             oShellLink1.TargetPath = "X:\" 
  71.             oShellLink1.WindowStyle = 1  
  72.             oShellLink1.Description = "研发中心共享文件" 
  73.             oShellLink1.WorkingDirectory = "X:\" 
  74.             oShellLink1.Save  
  75.         Case "采购部" 
  76.             objNetwork.MapNetworkDrive "X:"" \\fileserver\采购部$" 
  77.             Set oShellLink1 = WshShell.CreateShortcut(strDesktop & "\采购部共享文件组.lnk")  
  78.             oShellLink1.TargetPath = "X:\" 
  79.             oShellLink1.WindowStyle = 1  
  80.             oShellLink1.Description = "采购部共享文件" 
  81.             oShellLink1.WorkingDirectory = "X:\" 
  82.             oShellLink1.Save  
  83.         Case "品质部" 
  84.             objNetwork.MapNetworkDrive "X:"" \\fileserver\品质部$" 
  85.             Set oShellLink1 = WshShell.CreateShortcut(strDesktop & "\品质部共享文件组.lnk")  
  86.             oShellLink1.TargetPath = "X:\" 
  87.             oShellLink1.WindowStyle = 1  
  88.             oShellLink1.Description = "品质部共享文件" 
  89.             oShellLink1.WorkingDirectory = "X:\" 
  90.             oShellLink1.Save  
  91.  
  92.     End Select