Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hi all
Great site this, very valuable help:rem **mybatch file**
set /P IPHOST=Please enter the HOSTNAME or IP address of the Computer:
echo IP address is %IPHOST%WMIC /NODE: %IPHOST% COMPUTERSYSTEM GET NAME > rhost.txt
rem set /p remhost= < rhost.txt ***not using***
WMIC /NODE: %IPHOST% COMPUTERSYSTEM GET USERNAME > wmic.txt
rem set /p USRID= < wmic.txt ***not using***
more rhost.txt
more wmic.txt
echo.FOR /F "skip=1" %%A in (rhost.txt) DO set rhost=%%A
FOR /F "skip=1" %%C in (wmic.txt) DO set USR=%%Cecho %IPHOST% %rhost% %USR%
rem **end**I am expecting it to display IPaddress Hostname Username
but all I get it is IPaddress
and the other two are blankAny ideas?

HI IVO
I worked out that it was the text files created by the WMIC command wouldn't parse. (maybe trailing spaces or LF or CR character - don't know)
I worked out I only had to run the command once and get both variables.
I had to then output it to another text file and parse thatWMIC /NODE: %IPHOST% COMPUTERSYSTEM GET NAME, USERNAME > wmic.txt
type wmic.txt >pcinfo.txt
echo.FOR /F "skip=1" %%G in (pcinfo.txt) DO set rhost=%%G
FOR /F "skip=1 tokens=2" %%H in (pcinfo.txt) DO set usr=%%HOutput of both files looked identical
Name UserName
MYPCNAME MYUSERIDI am modifying it a bit more, and will post it when finished (minus any company specific info of course)
Thanks

![]() |
iTunes VBS or Perl script
|
copy files from folder A ...
|
| Login or Register to Reply | |
| Login | Register |
| Ads by Google |