可以使用登錄腳本指派用戶登錄特定計(jì)算機(jī)時(shí)將執(zhí)行的任務(wù)。該腳本可以執(zhí)行操作系統(tǒng)命令、設(shè)置系統(tǒng)環(huán)境變量以及調(diào)用其他腳本或可執(zhí)行程序。
下例中的登錄腳本含有使用了“Active Directory 服務(wù)接口 (ADSI)”的 VBScript 命令,它可按照用戶的組成員身份執(zhí)行三個(gè)常見任務(wù):
創(chuàng)建登錄腳本示例
Const ENGINEERING_GROUP = "cn=engineering"
Const FINANCE_GROUP = "cn=finance"
Const HUMAN_RESOURCES_GROUP = "cn=human resources"
Set wshNetwork = CreateObject("WScript.Network")
wshNetwork.MapNetworkDrive "h:",
"\\FileServer\Users\" & wshNetwork.UserName
Set ADSysInfo = CreateObject("ADSystemInfo")
Set CurrentUser = GetObject("LDAP://" &
ADSysInfo.UserName)
strGroups = LCase(Join(CurrentUser.MemberOf))
If InStr(strGroups, ENGINEERING_GROUP) Then
wshNetwork.MapNetworkDrive "g:",
"\\FileServer\Engineering\"
wshNetwork.AddWindowsPrinterConnection
"\\PrintServer\EngLaser"
wshNetwork.AddWindowsPrinterConnection
"\\PrintServer\Plotter"
wshNetWork.SetDefaultPrinter
"\\PrintServer\EngLaser"
ElseIf InStr(strGroups, FINANCE_GROUP) Then
wshNetwork.MapNetworkDrive "g:",
"\\FileServer\Finance\"
wshNetwork.AddWindowsPrinterConnection
"\\PrintServer\FinLaser"
wshNetWork.SetDefaultPrinter
"\\PrintServer\FinLaser"
ElseIf InStr(strGroups, HUMAN_RESOURCES_GROUP) Then
wshNetwork.MapNetworkDrive "g:",
"\\FileServer\Human Resources\"
wshNetwork.AddWindowsPrinterConnection
"\\PrintServer\HrLaser"
wshNetWork.SetDefaultPrinter
"\\PrintServer\HrLaser"
End If
src="ms-its:c:\windows\help\UAshared.chm::/note.gif"> 注意
有關(guān)創(chuàng)建和使用登錄腳本的詳細(xì)信息,請(qǐng)參閱 target=_new>Microsoft 網(wǎng)站中的href="MS-ITS:Lsconcepts.chm::/sag_LStopnode.htm">登錄腳本、Windows 腳本class=printOnly> (http://www.microsoft.com/) 以及 title=http://www.microsoft.com/
target=_new>Microsoft Windows 資源工具包網(wǎng)站(http://www.microsoft.com/)。