Why the command RunProgram doesn't work

Just starting out? Need help? Post your questions and find answers here.
simkot
User
User
Posts: 31
Joined: Sat Oct 26, 2024 8:25 am

Why the command RunProgram doesn't work

Post 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?
Quin
Addict
Addict
Posts: 1135
Joined: Thu Mar 31, 2022 7:03 pm
Location: Colorado, United States
Contact:

Re: Why the command RunProgram doesn't work

Post 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.
infratec
Always Here
Always Here
Posts: 7662
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: Why the command RunProgram doesn't work

Post by infratec »

And maybe you need the full path to net, since you don't start a shell ("cmd /C")
User avatar
blueb
Addict
Addict
Posts: 1118
Joined: Sat Apr 26, 2003 2:15 pm
Location: Cuernavaca, Mexico

Re: Why the command RunProgram doesn't work

Post 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
- It was too lonely at the top.

System : PB 6.21(x64) and Win 11 Pro (x64)
Hardware: AMD Ryzen 9 5900X w/64 gigs Ram, AMD RX 6950 XT Graphics w/16gigs Mem
Post Reply