Page 1 of 1

Why the command RunProgram doesn't work

Posted: Fri Nov 01, 2024 7:11 am
by simkot
Why the command doesn't work?

Code: Select all

RunProgram("net use ะต: \\192.168.1.1\WD")
When I execute it in Windows command line it works fine. But in script it doesn't work. Why?

Re: Why the command RunProgram doesn't work

Posted: Fri Nov 01, 2024 7:17 am
by Quin
Take a closer look at the docs for RunProgram()... :wink:
Result = RunProgram(Filename$ [, Parameter$, WorkingDirectory$ [, Flags [, SenderProgram]]])
Description
Launches an external program.
Parameters
Filename$
The executable name including its path.
Parameters$ (optional)
Specifies the command line parameters that will be passed to the program.
...snip...
So, you'd want "net" to be your first string, and everything after that should be in the second parameter.

Re: Why the command RunProgram doesn't work

Posted: Fri Nov 01, 2024 7:48 am
by infratec
And maybe you need the full path to net, since you don't start a shell ("cmd /C")

Re: Why the command RunProgram doesn't work

Posted: Fri Nov 01, 2024 1:54 pm
by blueb
This will give you a starting point...

Code: Select all

compiler = RunProgram("cmd.exe" , "/c netstat -n", "", #PB_Program_Open | #PB_Program_Read | #PB_Program_Hide)
Debug compiler
Debug "---"
Output$ = ""
If compiler
   Debug "I'm in"
       While ProgramRunning(Compiler)
        If AvailableProgramOutput(Compiler)
           Output$ + ReadProgramString(Compiler) + Chr(13)
           Debug Output$
        EndIf
    Wend
  KillProgram(compiler)
  CloseProgram(compiler)
EndIf