Hi I need help with a For /F Tokens batch

November 17, 2010 at 15:59:25
Specs: Windows XP
Hi, I am having a problem with this batch file. What am I doing wrong? I do not get any information in my results file, or the echo that shows up on screen
I am trying to pull memory, serial, IP, etc out of info.txt. In info.txt is this information
System Name: comp12
Memory: 1064673280
Serial Number: 2UA648870
Make: Hewlett-Packard Model: DSDT
Number of Processors: 1
CPU Speed: 3391
Mac Address: 00:11:22:33:44:55
IP Address: 192.168.100.226
Printer: LOD6

Here is my code I am trying to do

@ECHO OFF
SETLOCAL
SET VER=%DATE%.0.1
SET SOURCE_PATH=%~dp0
SET SOURCE_PATH=%SOURCE_PATH:~0,-1%
SET ProgPath=%~dp0
SET ProgPath=%ProgPath:~0,-1%
SET ProgName=%~nx0
SET ProgFile="%~f0"
SET ProgTitle=%~n0
SET TempPath=%~sf0
SET USER_ID=%USERNAME%
SET Clinical=NO
SET Autologon_acct=


IF [%USERNAME%]==[Administrator] GOTO ACCOUNT_ERROR
IF [%USERNAME%]==[ntwadmin] GOTO ACCOUNT_ERROR

:READY_LOG
IF EXIST %SystemDrive%\%COMPUTERNAME%.txt.old DEL /F /Q %SystemDrive%\%COMPUTERNAME%.txt.old
IF EXIST %SystemDrive%\%COMPUTERNAME%.txt REN %SystemDrive%\%COMPUTERNAME%.txt %COMPUTERNAME%.txt.old

IF EXIST %SystemDrive%\CHECKLIST.txt.old DEL /F /Q %SystemDrive%\CHECKLIST.txt.old
IF EXIST %SystemDrive%\CHECKLIST.txt REN %SystemDrive%\CHECKLIST.txt CHECKLIST.txt.old

::===================================================================
::START WMI Calls
SET COMPUTERNAME
cscript checkmps.vbs > info.txt


FOR /F "Tokens=2 DELIMS=: " %%A IN (info.txt) DO FOR %%B in (%%a) DO (
SET Memory=%%G
SET Serial=%%H
SET CPU=%%I
SET Model=%%J

)
pause

::END WMI Calls
::===================================================================
ECHO Checking for the Image Version.....
::Get Version
For /F "Tokens=3*" %%a In ('Reg Query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v ProductName') Do SET VER=%%a %%b
ECHO %VER%
::End Get Version
ECHO.

ECHO Checking for IP Address and FQDN.....
:IP_INFO
FOR /F "TOKENS=2 DELIMS=:" %%A IN ('IPCONFIG /ALL ^| FIND "IP Address"') DO FOR %%B IN (%%A) DO SET IPADDR=%%B&&GoTo :Break
:Break
FOR /F "TOKENS=2 DELIMS=:" %%A IN ('IPCONFIG /ALL ^| FIND "Connection-specific DNS Suffix"') DO FOR %%B IN (%%A) DO SET FQDN=%%B
ECHO.


ECHO ==================================================================== >%SystemDrive%\%COMPUTERNAME%.txt
ECHO Begin Configuration Process >>%SystemDrive%\%COMPUTERNAME%.txt
ECHO %DATE%, %TIME% >>%SystemDrive%\%COMPUTERNAME%.txt
ECHO PC Name: %COMPUTERNAME% User Name: %USER_ID% >>%SystemDrive%\%COMPUTERNAME%.txt
ECHO Model: %model% Barcode: %SERIAL% >>%SystemDrive%\%COMPUTERNAME%.txt
ECHO CPU Speed: %CPU% Memory: %Memory% MB >>%SystemDrive%\%COMPUTERNAME%.txt
ECHO Building: %FacilityCode% >>%SystemDrive%\%COMPUTERNAME%.txt
ECHO Version: %VER% >>%SystemDrive%\%COMPUTERNAME%.txt
ECHO IP: %IPADDR% >>%SystemDrive%\%COMPUTERNAME%.txt
ECHO PRINTER: %PRINTER% >>%SystemDrive%\%COMPUTERNAME%.txt >>%SystemDrive%\%COMPUTERNAME%.txt
ECHO FQDN: %FQDN% >>%SystemDrive%\%COMPUTERNAME%.txt
ECHO ==================================================================== >>%SystemDrive%\%COMPUTERNAME%.txt

:SRV_BLT1
CLS
ECHO ===========================================================
ECHO This program will assist in finalizing a PC build...
ECHO.
ECHO PC Name: %COMPUTERNAME% User Name: %USER_ID%
ECHO Model: %model% Barcode: %SERIAL%
ECHO CPU Speed: %CPU% Memory: %Memory% MB
ECHO Building: %FacilityCode%
ECHO Version: %VER%
ECHO IP: %IPADDR%
ECHO PRINTER: %PRINTER% >>%SystemDrive%\%COMPUTERNAME%.txt
ECHO FQDN: %FQDN%

ECHO ===========================================================
ECHO.
ECHO The following options will be displayed:
ECHO 1. Install Altiris
ECHO 2. Install Credant
ECHO 3. Install Office 2003
ECHO 4. Install Printers using universal print driver
ECHO 5. Install Autologon
ECHO.
ECHO ===========================================================


See More: Hi I need help with a For /F Tokens batch

Report •


#1
November 18, 2010 at 08:28:25
FOR /F "Tokens=2 DELIMS=: " %%A IN (info.txt) DO FOR %%B in (%%a) DO (
SET Memory=%%G
SET Serial=%%H
SET CPU=%%I
SET Model=%%J

)
You have %%A, and %%B. Where are you getting %%a, %%G, %%H, %%I, and %%J?

How To Ask Questions The Smart Way


Report •
Related Solutions


Ask Question