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 = streammunicate()[0].decode()
print(streammunicate()[0])
test.txt
is:
powershell -NoProfile "$ErrorActionPreference='silentlycontinue'; $tmp = (Get-Item -Path "$env:PROGRAMFILES\Google\Chrome\Application\chrome.exe").VersionInfo.FileVersion; if ($tmp) {echo $tmp; Exit;}; $tmp = (Get-Item -Path "${env:PROGRAMFILES(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.