Archive: Call vbscript and get output


Call vbscript and get output
I am writing an installer that needs to put some files on the root virtual web folder usually its c:\inetput\wwww but not always. I have written a vbscript that finds the root folder for me. What would be the easiest way to get the output from the script into nsis?


I think it would be much easier and more reliable if you detect the location the "root virtual web folder" directly in your NSIS installer. Why do you need VBScript? Also your installer would fail, if the user has disabled the Windows Scripting Host, because your VBScript cannot run. Howevery, if you still want to do it, try like that:

nsExec:execToLog '"$SYSTEM\CScript.exe" "$INSTDIR\foobar.vbs"'


Your script will need to write the desired output to the console. nsExec will redirect the console output into the installer where it can be processed...

Is there a way of detecting the root web folder from nsis?


Originally posted by patelb
Is there a way of detecting the root web folder from nsis?
If there is a way in VBScript, then I think there is one in NSIS too :D

1. You can read values from the Registry in NSIS easily
2. You can call Win32 API functions by using the NSIS "System" plugin
3. You can create your own custom NSIS Plugin, if needed


How do you do it in your VBScript ???? :confused:

I took an existing script and condensed it to this:

strComputer = "."
Set objWMIService = GetObject _
("winmgmts:{authenticationLevel=pktPrivacy}\\" _
& strComputer & "\root\microsoftiisv2")
Set colItems = objWMIService.ExecQuery _
("Select * from IIsWebVirtualDirSetting")
For Each objItem in colItems
Wscript.Echo "Path: " & objItem.Path
exit for
Next

The first output is the only thing I care for that is why I am exiting, yes I know its not neat but I just copied and pasted and it works!


I'm not a VBScript coder, so I don't understand that code.

But I'm pretty sure the Root Dir of the WWW Service is store in the Registry somewhere. In that case you can get it with a single "ReadRegStr" command in NSIS, you only need to find out the proper key. No VBScript would be needed. So this would be the most easy and reliable way.


However with your VBScript it should work like:

SetOutPath $INSTDIR
File "C:\My Scripts\Foobar.vbs"

nsExec:execToStack '"$SYSTEM\CScript.exe" "$INSTDIR\foobar.vbs"'
Pop $0

MessageBox MB_OK "Tada: $0"



But maybe you must use Cscript.Echo instead of Wscript.Echo ???


[EDIT]

Forget about it. Wscript.Echo works in Cscript.exe as well.
Just tried it :)

Ok cool thanks for the help! I know the way im doing it is really sloppy but it is the only way I could think of. Ill look in the www service being in the registry, but I dont think there is a key for it there.


Originally posted by patelb
Ok cool thanks for the help! I know the way im doing it is really sloppy but it is the only way I could think of. Ill look in the www service being in the registry, but I dont think there is a key for it there.
Where else than in the Registry should the IIS service store it's root dir?

Somewhere the root dir has to be stored physically...

Your right! Its here: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\InetStp\PathWWWRoot

Thanks!


Originally posted by patelb
Your right! Its here: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\InetStp\PathWWWRoot

Thanks!
Section
ReadRegStr $0 HKLM "SOFTWARE\Microsoft\InetStp" "PathWWWRoot"
MessageBox MB_OK "WWW Root: $0"
MessageBox MB_OK "This information was presented without any invocation of VBScrpt!"
SectionEnd