dwaynek Posted July 11, 2019 Share Posted July 11, 2019 (edited) trying to use this powershell command with Run but nothing comes out in $sOutput. the powershell portion works on the command line but not when its used in an autoit script: Local $iPID=Run('powershell "((gwmi win32_process | select CommandLine| Select-String -Pattern firefox.exe,GoogleChromePortable -CaseSensitive).line).split('-')|Select-String -Pattern CommandLine|Sort-Object|Get-Unique"', "d:\my documents\bat",@SW_SHOW,$STDOUT_CHILD + $STDERR_CHILD) ; Wait until the process has closed using the PID returned by Run. ProcessWaitClose($iPID) Local $sOutput = StdoutRead($iPID) msgbox(0,"",$sOutput) it has something to do with the split ('-') i think bcz if i remove everything from the line split portion onwards, it works fine. Edited July 11, 2019 by dwaynek Link to comment Share on other sites More sharing options...
Malkey Posted July 12, 2019 Share Posted July 12, 2019 Because the "program" parameter of the "Run" function is entirely incased within single quotes, ('...'), any single quotes, ('), within the "program" parameter must be doubled, (''), to be recognized as single quotes, ('..''...''..'). #include <AutoItConstants.au3> Local $iPID = Run('powershell "((gwmi win32_process | select CommandLine| Select-String -Pattern firefox.exe,GoogleChromePortable -CaseSensitive).line).split(''-'')|Select-String -Pattern CommandLine|Sort-Object|Get-Unique"', "", @SW_HIDE, $STDOUT_CHILD + $STDERR_CHILD) ; Wait until the process has closed using the PID returned by Run. ProcessWaitClose($iPID) Local $sOutput = StdoutRead($iPID) MsgBox(0, "", $sOutput) Link to comment Share on other sites More sharing options...
dwaynek Posted July 26, 2019 Author Share Posted July 26, 2019 awesome thanks that worked! Link to comment Share on other sites More sharing options...
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