ayu_2403 Posted June 17, 2023 Share Posted June 17, 2023 (edited) I want to run windows powershell and change to a particular directory and then list all the files in that directory using dir command how can I do that. I have tried below command but i don't know how to check the time when all the files have been listed. Run("Powershell.exe") WinWaitActive("Windows PowerShell") send('cd Z:/test' & "{ENTER}" & "dir" & "{ENTER}") I want to note the time it take to list files Edited June 17, 2023 by Melba23 Posts merged Link to comment Share on other sites More sharing options...
Solution sylremo Posted June 17, 2023 Solution Share Posted June 17, 2023 Local $hTimer = TimerInit() Local $sOutput = runPowershell('cd Z:/test; dir') MsgBox(262144, 'Took ' & TimerDiff($hTimer) & ' ms', $sOutput) Func runPowershell($sCommand) Return runCaptureOutput("powershell -Command " & $sCommand) EndFunc Func runCaptureOutput($sCommand) Local $iPid = Run(@ComSpec & " /c " & $sCommand, "", @SW_HIDE, 2 + 4) Local $sOutput = "" While (ProcessExists($iPid)) Sleep(50) WEnd Return StdoutRead($iPid) EndFunc Hope this helps. ayu_2403 1 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