Quantcast
Channel: AutoIt v3 - General Help and Support
Viewing all articles
Browse latest Browse all 12506

Interacting with powershell

$
0
0
Ive looked through a number of topics trying to get this to work to no avail.  Basically, I have some powershell scripts that I want to tie to a GUI, and the commands have to be powershell (theyre active-directory commands that have to be issued through a specific snap-in; doing them straight through AD will fail).

I am able to interact with a normal command prompt using stdinwrite and stdoutread, but using the exact same code for powershell simply doesnt work.  I wanted to see if anyone has dealt with / solved this issue.  Heres an example of the code Im using:
Global $data, $title, $pid
$pid = Run(@ComSpec, @SystemDir, @SW_SHOW, $STDIN_CHILD + $STDOUT_CHILD) ;WORKS

;;$pid = Run("C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -noexit", @SystemDir, @SW_SHOW, $STDIN_CHILD + $STDOUT_CHILD) ; DOES NOT WORK

If ProcessWait($pid, 5) Then
	 _StdIn('help /?')
	 _StdIn('ping -w 500 -n 1 8.8.8.8')
	 sleep(2000)
	 _StdOut()
EndIf
Exit



Func _StdIn($input)
	 If Not ProcessExists($pid) Then Return
	 StdinWrite($pid, $input & @CRLF)
EndFunc


Func _StdOut()
	 If Not ProcessExists($pid) Then Return
	 $output = StdOutRead($pid, 65500)
	 ConsoleWrite($output)
EndFunc


Viewing all articles
Browse latest Browse all 12506

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>