I want to automatically check if some KB is installed on the machine. Part of my python script:
import subprocess
result = subprocess.run(['cmd', '/c wmic qfe'], shell=True, stdout=subprocess.PIPE)
ftemp = open('mylog.txt','w') #just to check what is going wrong
ftemp.write(str(result.stdout))
ftemp.close()
if str(result.stdout).find('KB2999226')==-1:
print('Nah, you don't have KB')
sys.exit()
What I got in the shell while executing:
qfe" - Alias not found.
Nah, you don't have KB
mylog.txt:
b''
So, looks like some stupid problem with dashes or encodings. I've tried variety of commands, but nothing succeded. (Yeah, "dism" causes another tons of errors). Some advices?
'Nah, you don't have KB'
a typo?wmic path win32_quickfixengineering get KB2999226
working?- returns some unreadable text in the result.stdout, while
dism /Online /Get-Packages` works perfectly from the cmd.qfe" - Alias not found.
and not"qfe" - Alias not found.
??? In the latter case, what happens if you enter from the commandlinecmd /c wmic qfe
?