Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Using pipes in the RunConsole2 function's command
#1
Hi,

The code below, when executed, will output the prompt message: Invalid command.
However, it can be executed successfully in the actual cmd window.

Additionally, the part without the pipe symbol at the end(| findstr /i "diskindex") can be executed successfully.

I know that creating a temporary .bat file can solve the problem, but there is some sensitive information in my command, so I don't want to use a temporary file.

Is there a better solution?

Thanks in advance for any suggestions and help
David

Macro Macro21
Code:
Copy      Help
_s=
;wmic logicaldisk where "VolumeName='Win'" assoc:value /RESULTCLASS:Win32_DiskPartition | findstr /i "diskindex"
RunConsole2 _s
#2
In QM probably no.

In LA
Code:
Copy      Help
using var c = new consoleProcess("cmd");
c.Write("wmic logicaldisk where \"VolumeName='C'\" assoc:value /RESULTCLASS:Win32_DiskPartition | findstr /i \"diskindex\"");
var a = c.Prompt("C:*>", "exit");
print.it(a);
#3
thanks for your help,

Will temporary files be generated during the execution process?

Which assembly needs to be referenced?
[Image: c.png]
#4
No temp files.

LA 0.17.2.
#5
That's great!

Does it mean that the execution of multiline batch files no longer requires generating temporary files?

LA inherits all the advantages of QM. If we can train a ChatGPT chatbot to assist in code generation, there will be no limit to what it can do. Wink
#6
Code:
Copy      Help
str s=
;wmic logicaldisk where "VolumeName='C'" assoc:value /RESULTCLASS:Win32_DiskPartition | findstr /i "diskindex"

RunConsole2(F"cmd /c {s}")

If need multiple lines
Code:
Copy      Help
str bat=
;cd C:\
;dir

bat.findreplace("[]" "&&")
RunConsole2(F"cmd /s /c ''{bat}''")
#7
worked well, thank you!

Quote:str bat=
;cd C:\
;dir

bat.findreplace("[]" "&&")
RunConsole2(F"cmd /c ''{bat}''")

This approach may encounter errors in certain situations, especially when there is a lot of code. I have tried it several times before, and the only solution was to generate temporary .bat files to resolve it.


Forum Jump:


Users browsing this thread: 6 Guest(s)