For the .bat file named "strip_software_v1" that has code below, it exits during one or more of the for loops - indicating a problem (not running as desired).
I need to compare a list of software that is saved in %computername%-programs.txt file (I call file2) to that in Software excluded.txt (file3).
When a match is found - ie line in file3 matches a substring in file2, then this is ok, and consider the next one.
For entries that do not match, to append them into file4 (which is %computername%-programs-to-check.txt).
End result would be to end up with file4 listing any software in file2 on computer which isn't in file3.
The .bat file is called from within another batch file via call strip_software_v1.bat %file2%. Thus the parameter %1 in the code is %computername%-programs.txt.
@echo OFF
setlocal enableextensions enabledelayedexpansion
REM Echo ##################################################
set "Version_strip_software=v2"
REM Version: %Version_strip_software%
REM Modified 06/01/15 by Nick Prowse
REM Creates "%computername%-programs-to-check.txt" (%file3%), then checks software names in a text file %file2% (in this case %1)
REM against "software_excluded.txt", and if different appends to "%computername%-programs-to-check"
REM ====================================================
ECHO Running strip_software %Version_strip_software%
REM Path is %1 -- Path of %file2% parsed correctly
rem set "file2=%1"
set "file2=%computername%-programs.txt"
echo File2 is: %file2%
set "file3=%computername%-programs-to-check.txt"
if exist %file3% del %file3%
echo File3 is: %file3%
echo Strip Software %Version_strip_software% >> %file3%
echo Software to check: >> %file3%
echo -------------------- >> %file3%
pause
REM check each entry in
For /f "tokens=* delims=" %%A in (!file2!) do (
echo Inside 1st for
echo Inside 1st for >> %file3%
pause
For /f "tokens=* delims=" %%B in (software_excluded.txt) do (
echo Inside 2nd for
echo Inside 2nd for >> %file3%
pause
IF "%%A"=="%%B" (
) else (
echo %%A >> %file3%
)
)
)
"Software excluded.txt" (file2) currently contains the following:
Installed Applications
Adobe Flash
Cisco Jabber
Citrix
Dell KACE Agent
Hotfix for Microsoft
Installed Applications
Microsoft .Net
Security Update for Microsoft
Security Update for Windows
Sophos
Update for Microsoft
Update for Windows
Webfolders XP
Some content in %computername%-programs.txt is below:
Installed Applications
Adobe AIR
Version: 13.0
Cisco AnyConnect Secure Mobility Client
Citrix Receiver
Version: 13.1
K-Lite Codec Pack 10.7.5 Basic
Please advise
Aucun commentaire:
Enregistrer un commentaire