You are not logged in.
Pages: 1
I'm wondering how do you compare the results from one array to another? I'm trying not list users that are not logged in at the moment and then put the results in an array.
@ECHO OFF
SETLOCAL ENABLEDELAYEDEXPANSION
SET "a=0"
SET "b=0"
FOR /F "SKIP=1 TOKENS=1 DELIMS=> " %%a IN ('QUERY USER') DO (ECHO %%a is logged on
FOR /F %%c IN ('DIR /B C:\Users') DO (IF %%c NEQ Public IF %%c NEQ NTUSER.DAT IF "%%~c" NEQ "%%~a" SET PROFILE[!b!]=%%c& SET /A "b+=1" ELSE (ECHO %%c is not added))
SET PROFILE[
I got the idea to put in %%~a from http://stackoverflow.com/questions/2295 … two-arrays, but it doesn't seem to be working. Anyone have any ideas?
Offline
1. IF will only parse numbers when NEQ is used https://ss64.com/nt/if.html
2. You are missing a set of parens
3. You should quote values on both sides of ==
@ECHO OFF
SETLOCAL ENABLEDELAYEDEXPANSION
SET "a=0"
SET "b=0"
FOR /F "SKIP=1 TOKENS=1 DELIMS=> " %%a IN ('QUERY USER') DO (
ECHO %%a is logged on
FOR /F %%c IN ('DIR /B C:\Users') DO (IF /I NOT "%%c"=="Public" IF /I NOT "%%c"=="NTUSER.DAT" IF NOT "%%~c"=="%%~a" (SET PROFILE[!b!]=%%c& SET /A "b+=1") ELSE (ECHO %%c is not added)
)
)
SET PROFILE[
Windows Shell Scripting and InstallShield
Offline
Pages: 1