I am running this code import subprocess with open("test.txt", "r") as file: cmd = file.readline().strip() print("test") print(cmd) with subprocess.Popen( cmd, stdout=subprocess.PIPE, stdin=subprocess.DEVNULL, stderr=subprocess.DEVNULL, shell=True, ) as stream: # version = stream.communicate()[0].decode() print(stream.communicate()[0]) test.txt is: powershell -NoProfile "$ErrorActionPreference='silentlycontinue'; $tmp = (Get-Item -Path "$envROGRAMFILES\Google\Chrome\Application\chrome.exe").VersionInfo.FileVersion; if ($tmp) {echo $tmp; Exit;}; $tmp = (Get-Item -Path "${envROGRAMFILES(x86)}\Google\Chrome\Application\chrome.exe").VersionInfo.FileVersion; if ($tmp) {echo $tmp; Exit;}; $tmp = (Get-Item -Path "$env:LOCALAPPDATA\Google\Chrome\Application\chrome.exe").VersionInfo.FileVersion; if ($tmp) {echo $tmp; Exit;};" and sometimes I get the right result and sometimes I get nothing This command should return the current chrome version but it just don't sometimes. Continue reading...