今日与一些朋友调侃起各自的部门名称,有的IT部已经被用户公认为“挨踢”部,甚至有的IT部的分机号码都已被设置为119, 不知有多少ITPro被沦落为“救火员”,成就了传说中的“挨踢”, 业务与IT部门之间的哪些微秒之外到底在哪里?
今天要与大家分享的是AD用户在登入时执行的脚本,设置的位置位于AD用户属性的Logon Script处。因为该功能涉及到部分注册表的写入,因此根据条件判断通过Runasspc工具来分别运行两个辅助脚本,这两个脚本,明天与大家分享。
有关Runasspc的用法,请参考 官方网站(德国工艺,五星保证)。
该脚本指在为多家分支机构的用户提供通用的基本设置功能,包括自动增加和设置默认打印机,Citrix ICA快捷键、基本的截屏、USB和VNC等等的安全控制。
脚本存储位置:\\Domain\Netlogon
- '*************************************************
- ' Script : Users Logon Script
- ' Last Modified : 2010-07-27
- ' Version : 2.0
- '**************************************************
- On Error Resume Next
- ' CN Branch Printer
- Const nBranch = 10
- Const nPRN = 5
- Const nDept = 5
- Const HZ = 0
- Const SH = 1
- Const NJ = 2
- Const FZ = 3
- Const XM = 4
- Const JN = 5
- Const SZ = 6
- Const CQ = 7
- Const CR = 0
- Const HR = 1
- Const IT = 2
- Const AC = 3
- Const OM = 4
- ReDim arrBranch(nBranch - 1)
- arrBranch(0) = "HZ"
- arrBranch(1) = "SH"
- arrBranch(2) = "NJ"
- arrBranch(3) = "FZ"
- arrBranch(4) = "XM"
- arrBranch(5) = "JN"
- arrBranch(6) = "SZ"
- arrBranch(7) = "CQ"
- ReDim arrBWPRN(nBranch - 1 , nDept - 1)
- ReDim arrCOPRN(nBranch - 1 , nDept - 1)
- ReDim arrDePRN(nBranch - 1 , nDept - 1)
- arrBWPRN(HZ,0) = "\\hz2k3dc01\BWPrn1"
- arrBWPRN(HZ,1) = "\\hz2k3dc01\BWPrn2"
- arrCOPRN(HZ,0) = ""
- arrDePRN(HZ,CR) = 1
- arrDePRN(HZ,HR) = 1
- arrDePRN(HZ,IT) = 1
- arrDePRN(HZ,AC) = ""
- arrDePRN(HZ,OM) = ""
- arrBWPRN(SH,0) = "\\SH2k3dc01\BWPrn1"
- arrBWPRN(SH,1) = "\\SH2k3dc01\BWPrn2"
- arrCOPRN(SH,0) = "\\SHPUB235\BWPrn3"
- arrDePRN(SH,CR) = ""
- arrDePRN(SH,HR) = ""
- arrDePRN(SH,IT) = ""
- arrDePRN(SH,AC) = ""
- arrDePRN(SH,OM) = ""
- arrBWPRN(NJ,0) = "\\NJ2k3dc01\BWPrn1"
- arrBWPRN(NJ,1) = "\\NJ2k3dc01\BWPrn2"
- arrCOPRN(NJ,0) = ""
- arrDePRN(NJ,CR) = ""
- arrDePRN(NJ,HR) = ""
- arrDePRN(NJ,IT) = ""
- arrDePRN(NJ,AC) = ""
- arrDePRN(NJ,OM) = ""
- arrBWPRN(FZ,0) = "\\FZ2k3dc01\BWPrn1"
- arrBWPRN(FZ,1) = "\\FZ2k3dc01\BWPrn2"
- arrBWPRN(FZ,2) = "\\FZPUB235\BWPrn3"
- arrCOPRN(FZ,0) = "\\FZPUB235\COPrn1"
- arrDePRN(FZ,CR) = ""
- arrDePRN(FZ,HR) = ""
- arrDePRN(FZ,IT) = ""
- arrDePRN(FZ,AC) = ""
- arrDePRN(FZ,OM) = ""
- arrBWPRN(XM,0) = "\\XM2k3dc01\BWPrn1"
- arrBWPRN(XM,1) = "\\XM2k3dc01\BWPrn2"
- arrBWPRN(XM,2) = "\\XMPUB235\BWPrn3"
- arrCOPRN(XM,0) = ""
- arrDePRN(XM,CR) = ""
- arrDePRN(XM,HR) = ""
- arrDePRN(XM,IT) = ""
- arrDePRN(XM,AC) = ""
- arrDePRN(XM,OM) = ""
- arrBWPRN(JN,0) = "\\JN2k3dc01\BWPrn1"
- arrBWPRN(JN,1) = "\\JN2k3dc01\BWPrn2"
- arrCOPRN(JN,0) = "\\JNPUB235\BWPrn3"
- arrDePRN(JN,CR) = ""
- arrDePRN(JN,HR) = ""
- arrDePRN(JN,IT) = ""
- arrDePRN(JN,AC) = ""
- arrDePRN(JN,OM) = ""
- arrBWPRN(SZ,0) = "\\SZ2k3dc01\BWPrn1"
- arrBWPRN(SZ,1) = "\\SZ2k3dc01\BWPrn2"
- arrBWPRN(SZ,2) = "\\SZPUB235\BWPrn1"
- arrCOPRN(SZ,0) = "\\SZPUB235\coPrn1"
- arrDePRN(SZ,CR) = 1
- arrDePRN(SZ,HR) = ""
- arrDePRN(SZ,IT) = ""
- arrDePRN(SZ,AC) = 1
- arrDePRN(SZ,OM) = 1
- arrBWPRN(CQ,0) = "\\CQ2k3dc01\BWPrn1"
- arrBWPRN(CQ,1) = "\\CQ2k3dc01\BWPrn2"
- arrCOPRN(CQ,0) = "\\CQPUB235\BWPrn3"
- arrDePRN(CQ,CR) = ""
- arrDePRN(CQ,HR) = ""
- arrDePRN(CQ,IT) = ""
- arrDePRN(CQ,AC) = ""
- arrDePRN(CQ,OM) = ""
- '----------------------------------------------------------------
- Set WShell = CreateObject("wscript.shell")
- Set objNetwork = CreateObject("wscript.network")
- Set objFSO = CreateObject("scripting.FileSystemObject")
- Set objSysInfo = CreateObject("ADSystemInfo")
- strComputer = objNetwork.ComputerName
- UserName = objNetwork.UserName
- VCsite = Left(strComputer,2)
- RegInfo = 0
- If InStr(1,strComputer,"2K3",1) > 0 Then
- WScript.Quit
- Else
- 'Add Printer and set defualt Printer
- strUserPath = "LDAP://" & objSysInfo.UserName
- Set objUser = GetObject(strUserPath)
- For Each strGroup In objUser.Memberof
- strGroupPath = "LDAP://" & strGroup
- Set objGroup = GetObject(strGroupPath)
- strGroupName = objGroup.CN
- nSiteCode = GetSiteCode(VCSite)
- Select Case strGroupName
- 'Add Black and White Printer
- Case VCSite & "-Printer Users"
- For lngIndex = 0 to nBranch -1
- If arrBWPRN(nSiteCode, lngIndex) <> "" then
- objNetwork.AddWindowsPrinterConnection arrBWPRN(nSiteCode,lngIndex)
- End If
- Next
- 'Add Color Printer
- Case VCSite & "-Colour Printer Users"
- For lngIndex = 0 to nBranch -1
- If arrCOPRN(nSiteCode, lngIndex) <> "" then
- objNetwork.AddWindowsPrinterConnection arrCOPRN(nSiteCode,lngIndex)
- End If
- Next
- Case "Print-Screen-User"
- RegInfo = 1
- End Select
- Next
- 'set defualt Printer
- strDept = Left(objUser.DisplayName,4)
- nDeptCode = GetDeptCode(strDept)
- If nDeptCode < 99 and arrDePRN(nSiteCode, nDeptCode) <> "" Then
- objNetwork.SetDefaultPrinter arrBWPRN(nSiteCode, arrDePRN(nSiteCode, nDeptCode))
- ElseIf arrDePRN(nSiteCode, nDeptCode) = "" Then
- objNetwork.SetDefaultPrinter arrBWPRN(nSiteCode, 0)
- End If
- 'Map Network Drive
- objFSO.CreateFolder "\\" & Vcsite & "2k3dc01\Personal_Folder$\" & UserName
- objNetwork.MapNetworkDrive "P:","\\" & Vcsite & "2k3dc01\Personal_Folder$\" & UserName
- objNetwork.MapNetworkDrive "R:","\\" & VCsite & "2k3dc01\dept$"
- objNetwork.MapNetworkDrive "S:","\\" & VCsite & "2k3dc01\scan$"
- 'Set & Delete Regsitry Key Value
- If RegInfo = 1 Then
- wshell.Run("\\" & VCsite & "2k3dc01\netlogon\runasspc.exe /cryptfile:" & "\\" & VCSite & "2k3dc01\netlogon\Admin_Program\Special_Admin_Program.spc /quiet")
- Else
- wshell.Run("\\" & VCsite & "2k3dc01\netlogon\runasspc.exe /cryptfile:" & "\\" & VCSite & "2k3dc01\netlogon\Admin_Program\Default_Admin_Program.spc /quiet")
- End If
- End If
- GetSiteCode() GetSiteCode(strSite)
- For lngIndex = 0 To nBranch -1
- if strSite = arrBranch(lngIndex) then
- GetSiteCode = lngIndex
- End if
- Next
- End Function
- GetDeptCode() GetDeptCode(strDept)
- Select Case Mid(strDept,3,2)
- Case "CR"
- GetDeptCode = 0
- Case "HR"
- GetDeptCode = 1
- Case "IT"
- GetDeptCode = 2
- Case "AC"
- GetDeptCode = 3
- Case "OM"
- GetDeptCode = 4
- Case Else
- GetDeptCode = 99
- End Select
- End Function