executing caspol from within vbscript

  • Thread starter Thread starter Matt
  • Start date Start date
M

Matt

Hello group,

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
 
You cannot use the WScript object inside a Windows Installer custom action
VBScript. That's because you're not running inside the WScript hosting
object model, you're running in MSI's.

--
Phil Wilson
Definitive Guide to Windows Installer
http://www.apress.com/book/view/1590592972


Hello group,

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
 
I found that out yesterday, too :(

This however, works:

set sh = CreateObject("Wscript.Shell")
set env = sh.Environment("Process")

dim command
command = command & env("WINDIR")
command = command & "\microsoft.net\framework\v2.0.50727\caspol.exe"
command = command & " -pp off"
command = command & " -m"
command = command & " -ag 1"
command = command & " -url "
command = command & Session.Property("CustomActionData") & "\*"
command = command & " FullTrust"
command = command & " -name xxx"

sh.Exec(command)

The "Session" property is passed to the script via the
"CustomActionData" textbox for the custom action. There I've entered
"[SourceDir]", which returns the location of the msi for me. This
solution works on my test virtual machine (virgin Windows XP SP2).
 
Back
Top