#FEATURE by Stefan Reise
authorsr
Thu, 14 Nov 2019 14:03:19 +0100
changeset 24898 77318c4b1205
parent 24897 737da1130d4c
child 24899 e0fe5fb3c187
#FEATURE by Stefan Reise added: #executePowershellCommands:outputTo: comment/format in: #executePowershellCommands:
Win32OperatingSystem.st
--- a/Win32OperatingSystem.st	Mon Nov 11 20:51:07 2019 +0100
+++ b/Win32OperatingSystem.st	Thu Nov 14 14:03:19 2019 +0100
@@ -8148,6 +8148,39 @@
     "Modified: / 21-11-2012 / 12:14:06 / anwild"
 !
 
+executePowershellCommands:someCommands
+    outputTo:output
+
+    "
+        |output|
+
+        output := '' writeStream.
+
+        self 
+            executePowershellCommands:(Array with:'dir')
+            outputTo:output.
+
+        output contents inspect.
+    "
+
+    |input|
+
+    input := '' writeStream.
+    input nextPutAll:'powershell -noprofile -noninteractive "'.
+
+    someCommands do:[:eachCommand | 
+        input nextPutAll:((eachCommand subStrings:$") asStringWith:'\"').
+    ].
+
+    input nextPutAll:'"'.
+
+    OperatingSystem
+        executeCommand:input contents
+        outputTo:output.
+
+    "Created: / 14-11-2019 / 13:31:43 / Stefan Reise"
+!
+
 getAllProcesses
     "answer a sequence of OSProcess, all processes running in system"