Does variables get passed between scripts such that they can be used in the IF statement? I found that if i wanted to check the contents of #temp#\myfile.txt for a given string in the IF section of a stage 2 script then the script would fail saying that #temp# didn't exist. I have to specify the full path.
The problem with this is that it then makes using a #temp# variable for file locations pointless and I may as well use the absolute location in all my scripts.
Should this be the case? Can variables be passed between scripts and used in the IF statement? If so, how ?
Also, use #vagentconfiguration.agenttempdir# for the temp folder variable. This is a database 'view' that is pulled right from Kaseya dynamically. Check the help file for more explanation.
The important part about script variables is to remember that Kaseya used scoped variables. If you CALL one script from another script, the variable will exist in the second script. However, if you execute one script and that script is stand-alone...then separately you execute another script...that variable doesn't exist.
Also remember that you can't modify a variable in a subscript and have the variable value retained in the original script.
The other reason to use variables instead of hardcoding (even if you have to do it in every single script) for your temp directory is in case that temp directory changes. But as Ben said, using the SQL variable above is a better way to do it. A lot of the scripts you see that have "Get variable, Temp Directory" only do so because they were written before the SQL Views were exposed to scripting.