I'm trying to create a backup script in Kaseya Agent Procedure using the environemnt variables, I have manually set the environment variables on the machine %username% and %userprofile%. When I'm physically on the machine and type "set" in CMD, I see the path according to what I have set it to (using Control Panel, the "permanent" set solution). However, if I go into the "Command Shell" part of Live Connect and type in "set", it tells me that userprofile=c:\documents and settings\localservice. Screw localservice! Thus, my Kaseya Agent Procedure isn't working, it keeps using the localservice one intsead of the proper one that I configured.
Why is this happening?
Also.. what is the difference between "Execute as the logged on User" and "Execute as the System account" when creating the script? I've noticed in some of my scripts one will work but not the other (i.e. retrieving BIOS date information).
The Kaseya agent executes commands as the SYSTEM account unless you have specifically told the operation to execute as user, which will run as the user account specified under Agent --> Set Credential or the current user if that is not set. You can also use the "Impersonate User" operation and any below commands set to execute as user will run as the account you specified with the Impersonate User logon/password.
Okay, thanks for the elaboration Ben.
But back to the first part of my question, why is the Kaseya's Command Shell environment variables different than the ones that are set on the actual machine?
Kaseya does not have it's own unique command shell variables. When we execute processes, they run as the local system account -- that account has the variables Kaseya uses.
If you want to see for yourself what variables Kaseya will use if executing a shell command as the system account, go grab psexec from Microsoft (part of Pstools) and run it in a command prompt like this:
psexec -s cmd.exe
This will give you a command shell environment running as the system account. From here, you could do something like "echo %username%" or "echo %userprofile%" and see exactly what Kaseya will be using.