我想从 msi(设置项目)中自定义操作内的脚本中调用 caspol。与 ClickOnce 相比,我更喜欢标准 msi,因为使用标准 msi 我可以安装驱动程序并将文件类型与我们的应用程序相关联,而使用 ClickOnce 我不能。
当我从命令行执行 caspol 命令时,它会成功,但在 vbscript 中,它总是会失败,并出现错误“Fehler:Unbekannte Mitgliedschaftsbedingung - -url ..” - 翻译为“错误:未知的成员资格条件:-url”。进一步澄清:作为本地管理员,作为工作组的一部分,生成的命令的复制和粘贴直接在原始虚拟机的本地驱动器上的命令行上正常工作。
我有两个想法: 1. 我不是 vbscript 之王,所以也许我错过了引号或犯了其他类型的语法错误。2. Caspol 识别出我正在从脚本中运行它,并因故意的无意义错误而停止。
就个人而言,我相信这只是一个愚蠢的语法错误。
这是我的脚本:
set sh = CreateObject("Wscript.Shell")
Set fso = CreateObject("Scripting.FileSystemObject")
dim command
dim location
dim retVal
location = fso.GetFile(Wscript.ScriptFullName).ParentFolder
'%windir%\microsoft.net\framework\v2.0.50727\caspol.exe -pp off -m -addgroup 1 –url file://COMPUTER/SHARE/* FullTrust -name sbw2
command = fso.GetSpecialFolder(0) & "\microsoft.net\framework\v2.0.50727\caspol.exe -pp off -m -ag 1 –url file://"
for each s in Split(location, "\")
if Len(s) > 0 then
command = command & s & "/"
end if
next
command = command & "* FullTrust -name sbw2"
'DEBUG
'command = fso.GetSpecialFolder(0) & "\microsoft.net\framework\v2.0.50727\caspol.exe -m -ag 1 –url file://mjlaptop/sbw2/* FullTrust"
Wscript.StdOut.WriteLine VbClrf
Wscript.StdOut.WriteLine command
Wscript.StdOut.WriteLine VbClrf
Set output = sh.Exec(command)
dim text
while Not output.StdOut.AtEndOfStream
text = text & output.StdOut.Read(1)
Wend
Wscript.StdOut.WriteLine text
提前致谢,
马特