Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Troubleshooting
Research
Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

Script that records softwares need a change.

Avatar of bsharath
bsharathFlag for India asked on
Programming Languages-OtherScripting LanguagesWindows Batch
33 Comments1 Solution398 ViewsLast Modified:
Hi,

Script that records softwares need a change.
Need a way to log the machines names which were not recorded bacause they were off or they had permission issues.

need to way to record what the exact issue was for it not to record the softwares.

regards
Sharath
@echo off
set ServerLoc=\\inm\Logs\Software_Wise
if not exist %ServerLoc% exit /b

for /F "usebackq tokens=* delims=" %%a in ("%~dp0machins.txt") do call :QueryPC %%a
exit /b

:QueryPC
set pc=%1
if exist temp1.txt del temp1.txt
for /f "tokens=*" %%A in ('reg query "\\%pc%\hklm\software\microsoft\windows\currentversion\uninstall" ^| find /i 

"currentversion\uninstall\"') do (
@echo on
    reg query "\\%pc%\%%A" | find /i "parentkeyname">NUL
    if errorlevel 1 (
        reg query "\\%pc%\%%A" | find /i "systemcomponent" | find /i "0x1">NUL
        if errorlevel 1 (
            for /f "tokens=2,*" %%B in ('reg query "\\%pc%\%%A" ^| find /i " displayname"') do (
                echo %%C>>temp1.txt
            )
        )
    )
)
sort temp1.txt>temp2.txt
set LastLine=
for /f "tokens=*" %%A in (temp2.txt) do (
  if not "%%A"=="!LastLine!" (
    if exist "%ServerLoc%\%%A.txt" (
      findstr /i /b /e /c:"%pc%" "%ServerLoc%\%%A.txt">NUL
      if ERRORLEVEL 1 (
        echo %pc%>>"%ServerLoc%\%%A.txt"
      )
    ) else (
      echo %pc%>>"%ServerLoc%\%%A.txt"
    )
    set LastLine=%%a
  )
)
if exist temp1.txt del temp1.txt
if exist temp2.txt del temp2.txt
exit /b
ASKER CERTIFIED SOLUTION
Avatar of Qlemo
QlemoFlag of Germany image"Batchelor", Developer and EE Topic Advisor
Commented:
This problem has been solved!
Unlock 1 Answer and 33 Comments.
See Answers