AppDeploy.com

 


Scripting - %username% in batch files

Click here to associate this thread with a Package KB article.
Logged in as: Guest
Users viewing this topic: none
  Printable Version
All Forums >> [Dell KACE Appliances] >> K1000 Management Appliance >> Scripting - %username% in batch files Page: [1]
Login
Message << Older Topic   Newer Topic >>
Scripting - %username% in batch files - 1/22/2010 8:04:14 AM   
bwarren33

 

Posts: 2
Joined: 1/22/2010
Status: offline
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.
Post #: 1
RE: Scripting - %username% in batch files - 1/22/2010 8:49:22 AM   
airwolf


Posts: 563
Joined: 7/13/2009
From: teh interwebs
Status: offline
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.

_____________________________

Andy Flesner, MCSA - Flesner.com
author.programmer.serveradmin.gamer

Follow Me on Twitter

(in reply to bwarren33)
Post #: 2
RE: Scripting - %username% in batch files - 1/22/2010 8:55:43 AM   
airwolf


Posts: 563
Joined: 7/13/2009
From: teh interwebs
Status: offline
If you're interested in going the AutoIt route, I've found a function created by an AutoIt user to return the username of the console session (i.e. the person logged on directly to the machine).

http://www.autoitscript.com/forum/index.php?showtopic=102764

_____________________________

Andy Flesner, MCSA - Flesner.com
author.programmer.serveradmin.gamer

Follow Me on Twitter

(in reply to airwolf)
Post #: 3
RE: Scripting - %username% in batch files - 1/22/2010 9:27:44 AM   
bwarren33

 

Posts: 2
Joined: 1/22/2010
Status: offline
%computername% was good enough for me! excellent! thanks!

(in reply to airwolf)
Post #: 4
Page:   [1]
All Forums >> [Dell KACE Appliances] >> K1000 Management Appliance >> Scripting - %username% in batch files Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts


Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI

0.031