0

我想从 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

提前致谢,

马特

4

4 回答 4

0

不,不是这样。即使在所有字符串连接的末尾使用 command = command & """" 。

于 2008-11-17T10:24:19.873 回答
0

将您的答案复制并粘贴到我的代码中:

"C:\WINDOWS\microsoft.net\framework\v2.0.50727\caspol.exe -pp off -m -ag 1 -url "file://mjlaptop/sbw2/*" FullTrust -name sbw2

\\mjlaptop\sbw2\setpolicy.vbs(32, 1) WshShell.Exec: Das System kann die angegebene Datei nicht finden.

它缺少一个报价。现在,添加一个右引号,正如我猜你的意图:

"C:\WINDOWS\microsoft.net\framework\v2.0.50727\caspol.exe" -pp off -m -ag 1 -url "file://mjlaptop/sbw2/*" FullTrust -name sbw2

Microsoft (R) .NET Framework CasPol 2.0.50727.42
Copyright (c) Microsoft Corporation. Alle Rechte vorbehalten.

Fehler: Unbekannte Mitgliedschaftsbedingung - -url..

这是我原帖中给出的错误。你是对的:命令是有效的。该命令有效不是问题。我可以将血腥的回声复制并粘贴到命令窗口中,它会成功执行。我可以在其中添加任意数量的引号,但我认为它仍然会抱怨“未知的会员条件”。

我会尽量在评论中回复。

于 2008-11-17T15:04:27.330 回答
0

由于某种原因,将命令中 url 的 url 格式更改为 \\mjlaptop\sbw2*,格式为“file://...”将不起作用。带或不带引号。

这个 uid (yossarian) 也属于我 (Matt Jacobsen)。我不得不使用上述内容,因为 claimid 已停止维护。

于 2008-11-17T15:35:20.637 回答
0

"C:\WINDOWS\microsoft.net\framework\v\caspol" -pp off -m -ag 1 -url "file://mjlaptop/sbw2/*" FullTrust -name sbw2

Microsoft (R) .NET Framework CasPol 2.0.50727.42 版权所有 (c) Microsoft Corporation。Alle Rechte vorbehalten。

Fehler: Unbekannte Mitgliedschaftsbedingung - -url..

使用 v 而不是整个文件名允许代码在每个版本文件夹中搜索 caspol。

于 2014-01-21T22:28:29.820 回答