Search the Community
Showing results for tags 'delim'.
Hi all, More batch script goodness. I'm using PSTools' psloggedon for this. In CMD, if I input 'psloggedon -l -x \\HOSTNAME' I get the following result... Connecting to Registry of \\HOSTNAME... Users logged on locally: DOMAIN\USER_ONE DOMAIN\USER_TWO DOMAIN\USER_THREE DOMAIN\USER_FOUR Using FOR in a batch script, I would expect skipping the first 2 populated lines (using /F) and setting the delimiter as '\' should allow me to pipe just the usernames to the screen, however it isn't working. I am using the following... @echo off for /f "skip=2 tokens=2 delims=\" %%a in ('psloggedon -l -x \\%Hostname%') do set "LoggedOnUsers=%%a" echo "%LoggedOnUsers%" ...which results in the variable %LoggedOnUsers% being echo'd as simply... USER_TWO The end result I am aiming for is to output a list of all usernames logged on to a Hostname, regardless of whether it's just 1 user or many users, and then offer a CHOICE to the user of which username they want to select. For example, if a machine had 4 users logged on to it, the return would be; A. USER_ONE B. USER_TWO C. USER_THREE D. USER_FOUR Select a user : A,B,C,D [set variable based on whether input is A, B, C or D to the username for that selection] Where am I going wrong? Thank you. *edit* Amended spelling.