我想从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提前谢谢你,
哑光
发布于 2008-11-17 15:35:21
由于某种原因,将命令中url的url格式更改为\mjlaptop\sbw2*,格式为"file://...“行不通的。带或不带引号。
这个uid (yossarian)也属于我(Matt Jacobsen)。我不得不使用上面的代码,因为为了维护而关闭了claimid。
发布于 2008-11-17 10:24:20
不不是这样的。即使command = command &“在所有字符串连接的末尾。
发布于 2008-11-17 15:04:27
将您的答案复制粘贴到我的代码中:
"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..这就是我最初的帖子中给出的错误。您是对的:该命令是有效的。命令是否有效并不是问题所在。我可以将血淋淋的回显复制并粘贴到命令窗口中,它就会成功执行。我可以在其中插入任意多的引文,但我估计它仍然会抱怨“未知的会员条件”。
我会试着在评论中做出回复。
https://stackoverflow.com/questions/295209
复制相似问题