Scripting - %username% in batch files
Hi,
I'm using a script where i'm piping a command to a text file on around 1000 pc's so for easy individual results i'm piping the command to %username%.txt in a batch file. This works without a problem if I run the command manually on a machine but when I put the command in to a Kace script i just get files generated called .txt instead of bob.txt, mary.txt, jim.txt etc
I understand this is probably due to the command running as the local system account instead of the user logged in.
Any idea on how I can get around this little problem?
Thanks!
Ben.
I'm using a script where i'm piping a command to a text file on around 1000 pc's so for easy individual results i'm piping the command to %username%.txt in a batch file. This works without a problem if I run the command manually on a machine but when I put the command in to a Kace script i just get files generated called .txt instead of bob.txt, mary.txt, jim.txt etc
I understand this is probably due to the command running as the local system account instead of the user logged in.
Any idea on how I can get around this little problem?
Thanks!
Ben.
0 Comments
[ + ] Show comments
Answers (3)
Please log in to answer
Posted by:
airwolf
14 years ago
You could write an AutoIt script to perform a RunAs or select a username from a logged on session that isn't the local SYSTEM account. I don't think there is any way you can accomplish your goal using KBOX scripting. Scripts will all run as SYSTEM, and the %username% variable is dependent on the profile the script is run in. You could try using the machine name instead of the username, but if you want the username you'll need to write some VBS or AutoIt to poll logged on users from active sessions.
Posted by:
airwolf
14 years ago
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
so that the conversation will remain readable.