Kaseya Community

Writing vars out to File

This question is not answered

 Hi Kaseya Users,

I am needing some help. I am trying to write the following lines to a file on the the server and then call the batch file. All sounds simple except the batch file has QUOTES and a Greater than sign. This seems to be sending the script into a spin.

#kworking# = Get Kworking Holding

#varActiveSessions# = #kworking#\ActiveSessions.txt

query session | find "Active" > #varActiveSessions#

for /f "tokens=3 usebackq" %%G in (#varActiveSessions#) do (reset session %%G)

The script is used for logging off all users in that are active off a terminal server. Why do I need this, well some software that we have scripted its install will not install if there is multiusers logged in. It is on a server and the software requires a session to be running. We have about 18 sites that run this software that needs updating every month.

A really big pain!

Things that I have tried are Using HTML Codes for the QUOTES & Greater Than sign, Putting the command in write text with out using VARS. I really don't want to have the batch and push it down as kworking is not in the same spot on all servers.

Any ideas would be great, as I know this is going to be possible.

All Replies
  • We can log off all users with Live Connect on the Task Manager area, Users tab. We can probably even see how Kaseya does it by viewing the system script with the ALT+click trick.

  • I think maybe what you're running into is an encoding problem with the text file. Try using the "Type" command on the Unicode text file to convert it to ASCII before doing the rest of the work on it. For example:

    TYPE ActiveSessions.txt > ActiveSessionsASCII.txt

  • Oops.... small correction to my post above: the Reboot tab is where you will find the "Log Off" users options. I also took a peak at the system script and it appears to use an executable from the VSAHidden directory. Should be simple enough to replicate it if you choose to go that route.