CutterButter Posted January 8 Posted January 8 In Windows 10 Powershell I'm able to run: (Get-Item "c:\windows\system32\cmd.exe").VersionInfo.ProductVersion I get this result : 10.0.19041.1 I'd like to run this command and using these variables: $PSH = "powershell" $myExePath = "c:\windows\system32\cmd.exe" $CMD = $PSH & '(Get-Item "$myExePath").VersionInfo.ProductVersion' $result = Runwait(@ComSpec & " /c " & $CMD, "", @SW_HIDE) How can I make it ?
ajag Posted January 8 Posted January 8 $CMD = $PSH & '(Get-Item "' & $myExePath & '").VersionInfo.ProductVersion' Rule #1: Always do a backup Rule #2: Always do a backup (backup of rule #1)
argumentum Posted January 8 Posted January 8 Use this if you'd like. Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting.
rudi Posted January 13 Posted January 13 (edited) use the buildin fuction FileGetVersion() $Version=FileGetVersion(@ComSpec) MsgBox(0,"@Comspec Version",@ComSpec & @CRLF & $Version) Edited January 13 by rudi argumentum 1 Earth is flat, pigs can fly, and Nuclear Power is SAFE!
rudi Posted January 13 Posted January 13 (edited) And another one: $result = Runwait(@ComSpec & " /c " & $CMD, "", @SW_HIDE) this will give you the exit code, not the result of your program. To catch the "output" you would need to read the output by using StdoutRead() #include <AutoItConstants.au3> $PID = Run($YourCommand, $WD, @SW_HIDE, $STDERR_MERGED) ; run(), do not use runwait() while ProcessExists($PID) sleep(200) wend $Output=StdoutRead($PID) StdioClose($PID) Edited January 13 by rudi Earth is flat, pigs can fly, and Nuclear Power is SAFE!
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now