I'd like to call caspol from within a script inside a custom action in an msi (setup project). I'd prefer a standard msi to ClickOnce, because with a standard msi I can install drivers & associate filetypes with our application whereas with ClickOnce I can't.
When I execute the caspol command from the command line it succeeds, but from within vbscript it always fails with the error "Fehler: Unbekannte Mitgliedschaftsbedingung - -url.." - which translates as "Error: Unknown membership condition: -url". To further clarify: A copy & paste of the generated command works fine on the command line directly on the local drive of a virgin virtual machine, as local administrator, as part of a workgroup.
I have two ideas: 1. I'm no vbscript king, so maybe I've missed quotes or made some other sort of syntax error. 2. Caspol recognises that I'm running it from within a script and halts with an intentionally nonsensical error.
Personally, I believe it's just a dumb syntax error.
Here's my script:
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
Thanks in advance,
Matt