| 1. |
Solve : FOR /F to search computer name in a text file and report to another text file.? |
|
Answer» I need to check the computer names in the text file for a string then report back to another text file with the results. I have an error with the FOR /F syntax in the first line, if I REM out the first line the script works?? You invoke the FOR metavariable %%a in the FOR /F line, but then you never use it in the loop. %%a will successively hold each of the lines in C:\Folder\Computerlist.txt but, as I say, you don't use it. Did you expect %computername% to hold something different each time around the loop? (that variable is a special one used by Windows to hold the host name of the local computer). Thank you, I forgot to get it to loop through the text file I guess, I will try to fix that.Geek-9pm I deployed software via GPO and now I need to see how many installs where successful so it will search the text file with the computer names and report back for each computer. I used a DSQuery for computers in certain OU's to DEPLOY the software via GPO.Your information is to little, and whats your purpose of you using the string...? maybe this is what your looking for. it's not tested but it should be error free @echo off color 17 title Made by Zask SET /p "Command1= Creating directory, what would you like to name it? : " set /p "Command2= Name of file 1. : " set /p "Command3= Name of file 2. : " if not exist "C:\%Command1%\" ( mkdir "C:\%Command1%\" if "!errorlevel!" EQU "0" ( echo Folder created successfully ) else ( echo Error while creating folder ) ) else ( echo Folder already exists ) copy /Y "%~f0" "C:\%Command1%" set nl=^& echo. echo %nl% %nl% %nl% echo @echo off >> C:\%Command1%\%Command2%.txt echo echo @echo off ^>^> C:\%Command1%\%Command3%.txt >> C:\%Command1%\%Command2%.txt echo echo %%date%% ; this is the variable for date ^>^> C:\%Command1%\%Command3%.txt >> C:\%Command1%\%Command2%.txt echo echo %%time%% ; this is the variable for time ^>^> C:\%Command1%\%Command3%.txt >> C:\%Command1%\%Command2%.txt echo echo %%computername%% ; this is the variable for the computer name ^>^> C:\%Command1%\%Command3%.txt >> C:\%Command1%\%Command2%.txt echo echo %%username%% ; this is the variable for user name ^>^> %Command1%\%Command3%.txt >> C:\%Command1%\%Command2%.txt echo null >> C:\%Command1%\Dont_remove!.tmp echo Files Created! pause :2 set /p "Command4= Start your folder (y/n). : " if %Command4%==y goto 3 if %Command4%==n goto 4 :3 start C:\%Command1% :4 echo About to create second file! pause cd C:\%Command1%\ ren *.txt *.bat echo %nl% %nl% %nl% call %Command2%.bat echo %nl% %nl% %nl% del /s *%command2%.bat echo Second file created! pause :end Thank you for the help, I am looking through computer names in a text file to check each computer for a certain string that will tell me if the software I sent out via GPO was installed successfully and put the outcome in a file called Report. I found something that worked for me: @ECHO OFF FOR F "usebackq tokens=*" a IN ("c:\Folder\ComputerNames.txt") DO ( "\\Server\Share\filever.exe" "\\a\C$\Program Files\File.dll" | findstr "1.2.3.4" && echo a %date% %time% Software Installed >> "C:\Folder\Report.txt"Quote from: Newbie0000 on December 12, 2015, 04:13:46 AM Thank you for the help, I am looking through computer names in a text file to check each computer for a certain string that will tell me if the software I sent out via GPO was installed successfully and put the outcome in a file called Report. I found something that worked for me: So you no longer need my help? |
|