What's wrong with this . . .

  • Thread starter Thread starter Barney
  • Start date Start date
B

Barney

I want to produce a list of clients running Windows NT, or
2000 on our network. NET VIEW won't work because all of
the client machines are 'Hidden'.

I want to avoid a static file because that requires
maintenance and does not detect if a computer is actually
running. Therefore, I was thinkning of the following ...


RCMD \\ServerName "NET SESSION" >%Temp%\Sessions.1

FOR /F "Tokens=1-4" %%A IN (%Temp%\Sessions.1) DO
CALL :FindOS %%A %%D

:FindOS
IF {%2} == {NT} ECHO %1 >>%Temp%\Sessions.2
IF {%2} == {2000} ECHO %1 >>%Temp%\Sessions.2


.. . .

but I am stuck here because of an "The syntax of the
command is incorrect" error.


What is wrong with this code?
 
I want to produce a list of clients running Windows NT, or
2000 on our network. NET VIEW won't work because all of
the client machines are 'Hidden'.

I want to avoid a static file because that requires
maintenance and does not detect if a computer is actually
running. Therefore, I was thinkning of the following ...


RCMD \\ServerName "NET SESSION" >%Temp%\Sessions.1

FOR /F "Tokens=1-4" %%A IN (%Temp%\Sessions.1) DO
CALL :FindOS %%A %%D

:FindOS
IF {%2} == {NT} ECHO %1 >>%Temp%\Sessions.2
IF {%2} == {2000} ECHO %1 >>%Temp%\Sessions.2


. . .

but I am stuck here because of an "The syntax of the
command is incorrect" error.


What is wrong with this code?


RCMD \\ServerName "NET SESSION" >%Temp%\Sessions.1

FOR /F "Tokens=1-4" %%a in ('type %Temp%\Sessions.1') DO (
set comp=%%a
if "%comp"~0,2%" EQU "\\" CALL :FindOS %%a %%d
)
goto someplace
:FindOS
IF {%2} == {NT} ECHO %1 >>%Temp%\Sessions.2
IF {%2} == {2000} ECHO %1 >>%Temp%\Sessions.2


Jerold Schulman
Windows: General MVP
JSI, Inc.
http://www.jsiinc.com
 
rold said:
RCMD \\ServerName "NET SESSION" >%Temp%\Sessions.1

FOR /F "Tokens=1-4" %%a in ('type %Temp%\Sessions.1') DO (
set comp=%%a
if "%comp"~0,2%" EQU "\\" CALL :FindOS %%a %%d
)
goto someplace
:FindOS
IF {%2} == {NT} ECHO %1 >>%Temp%\Sessions.2
IF {%2} == {2000} ECHO %1 >>%Temp%\Sessions.2
Hello Jerold,
looks like a typo in the if statement. Should be a colon instaed of "
if "%comp:~0,2%" EQU "\\" CALL :FindOS %%a %%d

The output at my pc isn't that constant. I.e. localhost without user etc
What about this one.

RCMD \\ServerName "NET SESSION" >%Temp%\Sessions.1
FOR /F "Tokens=1-4" %%a in ('findstr "NT 2000" %Temp%\Sessions.1') DO (
set comp=%%a
if "%comp:~0,2%" EQU "\\" CALL :FindOS %%a %%d
)
goto someplace
:FindOS
IF {%2} == {NT} ECHO %1 >>%Temp%\Sessions.2
IF {%2} == {2000} ECHO %1 >>%Temp%\Sessions.2
goto :EOF
 
Hello Jerold,
looks like a typo in the if statement. Should be a colon instaed of "
if "%comp:~0,2%" EQU "\\" CALL :FindOS %%a %%d

The output at my pc isn't that constant. I.e. localhost without user etc
What about this one.

RCMD \\ServerName "NET SESSION" >%Temp%\Sessions.1
FOR /F "Tokens=1-4" %%a in ('findstr "NT 2000" %Temp%\Sessions.1') DO (
set comp=%%a
if "%comp:~0,2%" EQU "\\" CALL :FindOS %%a %%d
)
goto someplace
:FindOS
IF {%2} == {NT} ECHO %1 >>%Temp%\Sessions.2
IF {%2} == {2000} ECHO %1 >>%Temp%\Sessions.2
goto :EOF

I like yours, thank you.


Jerold Schulman
Windows: General MVP
JSI, Inc.
http://www.jsiinc.com
 
In said:
I want to produce a list of clients running Windows NT, or
2000 on our network. NET VIEW won't work because all of
the client machines are 'Hidden'.

I want to avoid a static file because that requires
maintenance and does not detect if a computer is actually
running. Therefore, I was thinkning of the following ...


RCMD \\ServerName "NET SESSION" >%Temp%\Sessions.1

FOR /F "Tokens=1-4" %%A IN (%Temp%\Sessions.1) DO
CALL :FindOS %%A %%D

:FindOS
IF {%2} == {NT} ECHO %1 >>%Temp%\Sessions.2
IF {%2} == {2000} ECHO %1 >>%Temp%\Sessions.2


. . .

but I am stuck here because of an "The syntax of the
command is incorrect" error.


What is wrong with this code?

Don't forget that the session may be auto-disconnected so that a
running client system may at any point in time not actually have a
Session with the server.
 
Back
Top