本节中的样例脚本将在典型配置中安装程序。为了便于复制此样例脚本以及替换用户信息,所有变量项目使用相同的名称。日志文件名以所安装的产品为依据。可以在脚本中使用日志文件名,也可以将其更改为其他内容。
' 适用于 AutoCAD 2011 的脚本安装 - 英文版
option explicit
'
' 创建变量
dim shell
dim productType
dim strADSKFirstName
dim strADSKLastName
dim strADSKOrganization
dim strADSKSNPrefix
dim strADSKSNNumber
dim strADSKProdKey
dim strLocale
dim strACADStandaloneNetworkType
dim strADSKLicenseServerType
dim strADSKLicenseType
dim strADSKServerName
dim strADSKServerPath
dim strADSKServerHostID
dim strADSKPath
dim strSourcePath
'
' 脚本安装
Set shell = CreateObject("WScript.Shell")productType = "ACAD"
'
' 名称和组织信息
strADSKFirstName = "My First Name"
strADSKLastName = "My Last Name"
strADSKOrganization = "Organization"
'
' 序列号信息
strADSKSNPrefix = "123"
strADSKSNNumber = "12345678"
strADSKProdKey="ABCDE"
'本地信息,例如 en-US = US English、de-DE = Deutchland German、ja-JP = Japan Japanese
strLocale="" ' en-US, de-DE, ja-JP
'
' 安装源(例如,假设 D: 为安装介质)
strSourcePath = "D:\"
'
' 安装目标
strADSKPath = Shell.ExpandEnvironmentStrings("%ProgramFiles%") + “\Autodesk\” + "AutoCAD 2011" If strLocale <> "" Then strADSKPath = strADSKPath + " " + strLocale
strADSKPath = strADSKPath + "\"
'''''' 取消注释安装的相关版本 - 默认为单机
' 对于单机
RunStandaloneInstall()
'
' 对于单一网络许可服务器
' RunSingleLicenseServerInstall()
'
' 脚本结束
Wscript.quit()
'
Function RunStandaloneInstall
shell.run DefaultCommand(),2,1
end function
'
Function RunSingleLicenseServerInstall
' 使用正确信息更新许可服务器
strACADStandaloneNetworkType = "3"
strADSKLicenseServerType = "Single Server License"
strADSKLicenseType = "Network License"
strADSKServerPath = "myFlexNetServer"
' HOSTID 或 MAC 地址
strADSKServerHOSTID = "000000000000"
'
' 合并两个值
strADSKServerPath = strADSKServerPath & " " & strADSKServerHOSTID
shell.run MakeCommand(),2,1
end function
'
Function DefaultCommand
dim retString
' /qb 表示静默安装 ' /c [关键字] 是关键字的替代参数
' /w 等到安装完成之后再运行脚本
' /o 安装完成后重新启动
retString = """" & strSourcePath & "\setup.exe" & """" & " /t /qb "
If strLocale <> "" then
retString = retString & "/Language " & strLocale
End if
retString = retString & " /c " & productType & ": "
retString = retString & "INSTALLDIR=" & """" & strADSKPath & """" & " "
retString = retString & "ACADSERIALPREFIX=" & strADSKSNPrefix & " "
retString = retString & "ACADSERIALNUMBER=" & strADSKSNNumber & " "
retString = retString & "ADLM_PRODKEY=" & strADSKProdKey & " "
retString = retString & "ACADFIRSTNAME=" & """" & strADSKFirstName & """" & " "
retString = retString & "ACADLASTNAME=" & """" & strADSKLastName & """" & " "
retString = retString & "ACADORGANIZATION=" & """" & strADSKOrganization & """" & " "
retString = retString & "InstallLevel=5 "
DefaultCommand = retString & " "
end function
'
Function MakeCommand
dim retString
retString = DefaultCommand() & " "
retString = retString & "ACADSTANDALONENETWORKTYPE=" & """" & strACADStandaloneNetworkType & """" & " "
retString = retString & "ACADLICENSESERVERTYPE=" & """" & strADSKLicenseServerType & """" & " "
retString = retString & "ACADLICENSETYPE=" & """" & strADSKLicenseType & """" & " "
retString = retString & "ACADSERVERPATH=" & """" & strADSKServerPath & """" & " "
MakeCommand = retString
end function