PDA

View Full Version : No support of vbscript code in Basic project?



Peter Bi
06-27-2002, 11:43 AM
Hi,

When I executed a simple CA of vbscript (the code is 'Stored directly in the custom action'), I got error 1720. Here is the code:
--------------------------------------------
Dim WshShell, bKey
set WshShell = WScript.CreateObject("WScript.Shell")

bKey = WshShell.RegRead("HKLM\Software\Myproduct\InstallDir")

if Len(bKey)>1 then
Property("INSTALLDIR") = bKey
end if
-----------------------------------------------

It seems once I have WScript.CreateObject, it will produce the error. Does that mean that there is only restricted vbscript can be used for CA in Basic project? How can I create WScript objects (Shell, Network, etc.) in vbscript code?

Thanks,
Peter

TsungH
06-27-2002, 02:08 PM
Use CreateObject instead of WScript.CreateObject

Peter Bi
06-27-2002, 03:36 PM
No, still got the same error. The problem is on RegRead and RegWrite methods. It's either the object was not created properly or the object was created but the methods couldn't be invoked (not supported by Developer7?).
If I block the RegRead and RegWrite call (the script just do nothing except calling creatobject), the error is gone.

Thanks,
Peter

TsungH
06-27-2002, 06:38 PM
If you try to read a non-existing key, RegRead will fail, which will result in 1720. Test your VBScript standalone, remember to comment out all references to Session object. It is easier to debug while running a VBScript standalone.