'映射共享和在桌面建立快捷方式
'登录(logon)脚本
'On Error Resume Next
Set objSysInfo = CreateObject("ADSystemInfo")
Set objNetwork = CreateObject("Wscript.Network")
Set ObjFSO = Wscript.CreateObject("Scripting.FileSystemObject")
strUserPath = "LDAP://" & objSysInfo.UserName
Set objUser = GetObject(strUserPath)
dim WshShell
dim strDesktop
dim oShellLink1,oShellLink2
set WshShell = WScript.CreateObject("WScript.Shell")
strDesktop = WshShell.SpecialFolders("Desktop")
If(ObjFSO.DriveExists("Y:"))then
objNetwork.RemoveNetworkDrive"Y:",true
End If
If(ObjFSO.DriveExists("P:"))then
objNetwork.RemoveNetworkDrive"P:",true
End If
for each objgroup in objuser.groups
strGroupName = objGroup.CN
Select Case strGroupName
Case "13信息技术部"
objNetwork.AddWindowsPrinterConnection "\\打印机共享地址A"
objNetwork.SetDefaultPrinter "\\打印机共享地址A"
objNetwork.MapNetworkDrive "Y:", "\\文件服务器IP\Departments\信息技术部"
set oShellLink1 = WshShell.CreateShortcut(strDesktop & "\信息技术部.lnk")
oShellLink1.TargetPath = "Y:\"
oShellLink1.WindowStyle = 1
oShellLink1.Description = "信息技术部公用文件"
oShellLink1.WorkingDirectory = "Y:\"
oShellLink1.Save
objNetwork.MapNetworkDrive "P:", "\\文件服务器IP\全省共享"
set oShellLink2 = WshShell.CreateShortcut(strDesktop & "\广东分公司.lnk")
oShellLink2.TargetPath = "P:\"
oShellLink2.WindowStyle = 1
oShellLink2.Description = "全省共享公用文件"
oShellLink2.WorkingDirectory = "P:\"
oShellLink2.Save
Case "13人力资源部"
objNetwork.AddWindowsPrinterConnection "\\打印机共享地址B"
objNetwork.SetDefaultPrinter "\\打印机共享地址B"
objNetwork.MapNetworkDrive "Y:", "\\文件服务器\Departments\人力资源部"
set oShellLink1 = WshShell.CreateShortcut(strDesktop & "\人力资源部.lnk")
oShellLink1.TargetPath = "Y:\"
oShellLink1.WindowStyle = 1
oShellLink1.Description = "人力资源部公用文件"
oShellLink1.WorkingDirectory = "Y:\"
oShellLink1.Save
objNetwork.MapNetworkDrive "P:", "\\文件服务器\全省共享"
set oShellLink2 = WshShell.CreateShortcut(strDesktop & "\广东分公司.lnk")
oShellLink2.TargetPath = "P:\"
oShellLink2.WindowStyle = 1
oShellLink2.Description = "全省共享公用文件"
oShellLink2.WorkingDirectory = "P:\"
oShellLink2.Save
End Select
Next
转载于:https://blog.51cto.com/blacktoad/1180702