This content has been marked as final. Show 5 replies
Even a simple NiGetVar("ComputerName") is not working from VBScript. Do I need to do any change in the settings in NetInstall Manager to make it work?
Any help would be appreciated.
") and NiSetVar" ", should work without any special settings. The following example shows how to use the commands to get and set NetInstall variables from VBS.
The netinstall script might look like this:
The VBS might look like this:
var2=var1 & "-new"
The expected result is a message box with the following content:
If the result is not what you expect take a look into the NetInstall log. If there's something wrong with the variables or there is a syntax error in the VBS you will see it there.
Hope this helps
Thanks for your reply. I'm still not able to get the values of my variables. I'm not sure what I'm missing here. My netinstall log doesn't talk about any error or failure or warnings too.
I tried reading just NiGetVar("ComputerName") in my VBS and tried to print it in a text file, it doesn't even writes this value in the text file.
I figured out the problem. The actual problem was in the way I was invoking my VBScript. I've used execute command instead of callscript.
I don't know somehow execute is executing the VBS file using CScript but not retrieving the variable values. With CallScript, it is working fine.
Now it is working fine. Thanks for your inputs.
the cause you have to invoke your script via "CallScript" is that if you are using this command, then NetInstall is the script host. If you are invoking it via "Execute" then wscript.exe or cscript.exe is the host (the "host" is the application that loads the script interpreter engine, here vbscript.dll, and passes the script to it. The engine and the host then share the same execution context and can therefore exchange information). Other script hosts are for example Internet Explorer (that is the cause you can use VBScript code inside your html-pages) oder IIS (the scripts are then normally called ASP-pages).
As "NIGetVar" and "NISetVar" are no "normal" VBScript commands (you can't use these commands in any script not called by NetInstall), but they are provided by the NIRT (NetInstall Runtime) which acts as a the script host.
Please keep in mind, that you CANNOT use any methods/commands that are provided by the Windows scripthost (eg wscript.sleep or wscript.quit), because wscript is not involved when calling the script from inside NI and thus these commands would cause your script to fail.