我正在尝试编写 WSH 登录脚本。整个公司的管理员需要能够为特定位置和用户自定义脚本的执行,并执行其他脚本。为了让他们的工作更轻松,我想提供一个 API,管理员可以在他们的脚本中访问。如果我使用 JScript 编写我的 API,是否可以初始化我通过 VBScript 定义的对象?例如,考虑以下代码:
<!-- The WSF logon script file -->
<package>
<job>
<script language="JScript">
// A demonstration function
function OverNineThousand() {
return 9001;
}
// A demonstration "class"
function WorkstationClass() {
var os = "Windows XP";
this.getOperatingSystem = function() {
return os;
}
}
</script>
<script language="VBScript">
Dim bigNumber, workstation
'// This assignment works properly.
bigNumber = OverNineThousand()
'// This assignment causes an error. Am I doing it wrong?
Set workstation = New WorkstationClass()
'// Execution never gets this far
WScript.Echo workstation.getOperatingSystem()
</script>
</job>
</package>
有什么办法可以完成我想做的事情吗?