连接共享打印机的脚本

'On Error Resume Next
Set objSysInfo = CreateObject("ADSystemInfo")
Set objNetwork = CreateObject("Wscript.Network")
strUserPath = "LDAP://" & objSysInfo.UserName
Set objUser = GetObject(strUserPath)
set WshShell = WScript.CreateObject("WScript.Shell")
strDesktop = WshShell.SpecialFolders("AllUsersDesktop")
objMemberOf = objUser.MemberOf
If IsArray(objMemberOf) = False Then
        WScript.Echo objMemberOf
Else
        For Each strGroup in objUser.MemberOf
                strGroupPath = "LDAP://" & strGroup
                Set objGroup = GetObject(strGroupPath)
                strGroupName = objGroup.CN
                  Select Case strGroupName
               
 Case "CH_HRoffice"
               objNetwork.AddWindowsPrinterConnection " \\stchina1\CH_HRoffice"
                objNetwork.SetDefaultPrinter " \\stchina1\CH_HRoffice"
Case "CH_FINoffice"
               objNetwork.AddWindowsPrinterConnection " \\stchina1\CH_FINoffice"
                objNetwork.SetDefaultPrinter " \\stchina1\CH_FINoffice"
Case "CH_Officelsr2"
               objNetwork.AddWindowsPrinterConnection " \\stchina1\CH_Officelsr2"
                objNetwork.SetDefaultPrinter " \\stchina1\CH_Officelsr2"
Case "CH_Officelsr1"
               objNetwork.AddWindowsPrinterConnection " \\stchina1\CH_Officelsr1"
                objNetwork.SetDefaultPrinter " \\stchina1\CH_Officelsr1"
Case "CH_GMOffice"
               objNetwork.AddWindowsPrinterConnection " \\stchina1\CH_GMOffice"
                objNetwork.SetDefaultPrinter " \\stchina1\CH_GMOffice"
                End select
        Next
End If

 

本文出自 “Terry's IT experi..” 博客,转载请与作者联系!

你可能感兴趣的:(职场,脚本,休闲,打印机)