How to issue a command line instruction. [SOLVED]
How to issue a command line instruction. [SOLVED]
I am trying to find a way to issue a simple command line instruction to Windows from within a PB program.
TIA
Dave
TIA
Dave
Last edited by davebar on Fri Jul 16, 2021 9:04 pm, edited 1 time in total.
Re: How to issue a command line instruction.
Show PB Help RunProgram
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
Re: How to issue a command line instruction.
Thanks mk-soft, but RunProgram is not a solution to my issue.
I need to be able to issue a command in exactly the same way as if I opened the the windows command prompt and entered the command.
I am not running a program, I am issuing a direct Windows command line.
Obviously PB lacks his trivially simple facility, so I have resolved the issue with other software.
Regards
Dave
I need to be able to issue a command in exactly the same way as if I opened the the windows command prompt and entered the command.
I am not running a program, I am issuing a direct Windows command line.
Obviously PB lacks his trivially simple facility, so I have resolved the issue with other software.
Regards
Dave
Re: How to issue a command line instruction.
Why not try the following trvially simple facility?davebar wrote: ↑Fri Jul 16, 2021 8:55 pm Thanks mk-soft, but RunProgram is not a solution to my issue.
I need to be able to issue a command in exactly the same way as if I opened the the windows command prompt and entered the command.
I am not running a program, I am issuing a direct Windows command line.
Obviously PB lacks his trivially simple facility, so I have resolved the issue with other software.
Code: Select all
RunProgram("cmd.exe", "/c dir | more", GetPathPart(ProgramFilename()))
Re: How to issue a command line instruction.
RunProgram() can do that; I do it all the time to match command prompt queries. It's no problem to do and works great.
Not true at all. Why don't you post your command-line text and we'll show you how to do it with RunProgram()?
Re: How to issue a command line instruction. [SOLVED]
I hadn't intended to pursue this issue, but since a number of experienced PB users claim RunProgram will work, I would be interested to know how to do the following.
Run cmd.exe and have the Ver instruction display the version in the interpreter window.
I am only using the Ver instruction here as an example, because my real instruction would have raised too many "red herrings" [1]
Regards
Dave
[1] Definition: https://en.wikipedia.org/wiki/Red_herring
Run cmd.exe and have the Ver instruction display the version in the interpreter window.
I am only using the Ver instruction here as an example, because my real instruction would have raised too many "red herrings" [1]
Regards
Dave
[1] Definition: https://en.wikipedia.org/wiki/Red_herring
Re: How to issue a command line instruction. [SOLVED]
Here:
RunProgram() result:
The code that did it with RunProgram():
Code: Select all
Compiler = RunProgram("cmd.exe", " /c ver", "", #PB_Program_Hide | #PB_Program_Open | #PB_Program_Read)
If Compiler
While ProgramRunning(Compiler)
If AvailableProgramOutput(Compiler)
Output$ + ReadProgramString(Compiler) + Chr(13)
EndIf
Wend
Output$ + Chr(13) + Chr(13)
CloseProgram(Compiler)
EndIf
MessageRequester("Output", Output$)
BTW, I don't care about red herrings or such... so if you still can't get your thing to work with RunProgram(), ask here and I'll see what's going wrong.
Re: How to issue a command line instruction. [SOLVED]
Sorry this does not do what I was asking for.
I want the Windows version to appear and stay visible ONLY in the the command line window, without the MessageRequester.
Your code gives me the output ONLY in the MessageRequester and NO output in the command line window.
Regards
Dave
I want the Windows version to appear and stay visible ONLY in the the command line window, without the MessageRequester.
Your code gives me the output ONLY in the MessageRequester and NO output in the command line window.
Regards
Dave
Re: How to issue a command line instruction. [SOLVED]
Just that or what?
Code: Select all
RunProgram("cmd.exe", " /k ver",#Null$,#PB_Program_Open)
Re: How to issue a command line instruction. [SOLVED]
OK, Real progress. I replace your "/k ver" with "/k <my command line string>" and it works perfectly.
I now need to construct a string variable eg Command$ in order to get:
to do exactly the same thing.
Any thoughts?
Many thanks for your time and patience.
Regards
Dave
I now need to construct a string variable eg Command$ in order to get:
Code: Select all
RunProgram("cmd.exe", Command$, #Null$, #PB_Program_Open)
Any thoughts?
Many thanks for your time and patience.
Regards
Dave
Re: How to issue a command line instruction. [SOLVED]
Example:
Code: Select all
EnableExplicit
Procedure.i RunCMD(Command.s)
ProcedureReturn Bool(RunProgram("cmd.exe"," /k " + Command,#Null$) <> #Null)
EndProcedure
Debug RunCMD("ver")
End
Re: How to issue a command line instruction. [SOLVED]
Wow! And I thought Assembler and C++ were complicated to understand.
It's going to take me some time to figure out why this works in a procedure.
Again, thanks to all who contributed to this thread.
Regards
Dave
It's going to take me some time to figure out why this works in a procedure.
Again, thanks to all who contributed to this thread.
Regards
Dave
Re: How to issue a command line instruction. [SOLVED]
It comes as no surprise that the FANBOYS who contributed nothing to this thread would jump in with derogatory commentary after the fact. But sadly that's the way the world is today and one of the main reasons I stopped following this forum.
Re: How to issue a command line instruction. [SOLVED]
Put a bit of humour in your life man