[Abandoned effort] RunProgram Reading Between The Lines

Just starting out? Need help? Post your questions and find answers here.
Randy Walker
Addict
Addict
Posts: 1109
Joined: Sun Jul 25, 2004 4:21 pm
Location: USoA

[Abandoned effort] RunProgram Reading Between The Lines

Post by Randy Walker »

Windows 11 Pro...
Something wrong here. Probably me. I'm expecting debug lines here to be same as what I get running this command line at powershell prompt.
Of course these samples only work if you have LibreOffice 25.2.0.3 installed on your PC.

Here's the RunProgram command code:

Code: Select all

Exe = RunProgram("powershell.exe","winget upgrade "+Chr(34)+"LibreOffice 25.2.0.3"+Chr(34),"",#PB_Program_Hide|#PB_Program_Open|#PB_Program_Read|#PB_Program_Error)
If Exe
  While ProgramRunning(Exe)
    WindowEvent()
    If AvailableProgramOutput(Exe)
      Output$=ReadProgramString(Exe)
      Debug Output$
    EndIf
  Wend
  CloseProgram(exe)
EndIf

And Here's the command line for the powershell prompt:

winget upgrade "LibreOffice 25.2.0.3"

(Use Ctrl-C to abort if you don't want to upgrade)

Compare debug lines to output in powershell and they are completely different.
Last edited by Randy Walker on Fri Mar 07, 2025 11:30 pm, edited 1 time in total.
- - - - - - - - - - - - - - - -
Randy
I *never* claimed to be a programmer.
infratec
Always Here
Always Here
Posts: 7662
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: RunProgram Reading Between The Lines

Post by infratec »

Try to read the error output too.
Randy Walker
Addict
Addict
Posts: 1109
Joined: Sun Jul 25, 2004 4:21 pm
Location: USoA

Re: RunProgram Reading Between The Lines

Post by Randy Walker »

infratec wrote: Tue Mar 04, 2025 7:58 am Try to read the error output too.
Good thought i suppose but #PB_Program_Error is already there.
- - - - - - - - - - - - - - - -
Randy
I *never* claimed to be a programmer.
BarryG
Addict
Addict
Posts: 4219
Joined: Thu Apr 18, 2019 8:17 am

Re: RunProgram Reading Between The Lines

Post by BarryG »

The flag on its own isn't enough. You need to use ReadProgramError() as well, which isn't there.
Randy Walker
Addict
Addict
Posts: 1109
Joined: Sun Jul 25, 2004 4:21 pm
Location: USoA

Re: RunProgram Reading Between The Lines

Post by Randy Walker »

BarryG wrote: Tue Mar 04, 2025 10:13 am The flag on its own isn't enough. You need to use ReadProgramError() as well, which isn't there.
eh Ohhhh Ok, I'll try to figure out how to squeeze that in there.
Thanks BarryG !!!
- - - - - - - - - - - - - - - -
Randy
I *never* claimed to be a programmer.
Randy Walker
Addict
Addict
Posts: 1109
Joined: Sun Jul 25, 2004 4:21 pm
Location: USoA

Re: RunProgram Reading Between The Lines

Post by Randy Walker »

BarryG wrote: Tue Mar 04, 2025 10:13 am The flag on its own isn't enough. You need to use ReadProgramError() as well, which isn't there.
Ok so I added these two lines and commented the debug Output$ line and got nothing so I think ReadProgramError() is not the answer:

Code: Select all

Error$ = ReadProgramError(Exe)
DeBug Error$
- - - - - - - - - - - - - - - -
Randy
I *never* claimed to be a programmer.
BarryG
Addict
Addict
Posts: 4219
Joined: Thu Apr 18, 2019 8:17 am

Re: RunProgram Reading Between The Lines

Post by BarryG »

It might be, but we don't have your full snippet to see.
Randy Walker
Addict
Addict
Posts: 1109
Joined: Sun Jul 25, 2004 4:21 pm
Location: USoA

Re: RunProgram Reading Between The Lines

Post by Randy Walker »

BarryG wrote: Tue Mar 04, 2025 10:06 pm It might be, but we don't have your full snippet to see.
Can't finish until I can get full output from WinGet cmdlet so this is a work in progress:

Code: Select all

;WingetUpdater written by Randy Walker with no promises -- run at your own risk (02/26/2025)
Dim prog$(250)
Dim update$(250,2)
If OpenWindow(0, 0, 0, 322, 450, "WinGet Application Updater", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  EditorGadget(0, 8, 8, 306, 433)
  SetGadgetText(0,"Please wait while we perform a search . . .")
  AddGadgetItem(0, -1, "")
  AddGadgetItem(0, -1, "       NAME                  Update Ver   Current Ver")
  ;Exe = RunProgram("powershell.exe","winget upgrade YourAppHer","",#PB_Program_Open)
  ;Uncomment line above, comment line below and change YourAppHer with name of your preference from list in main window 
  Exe = RunProgram("powershell.exe","winget list","",#PB_Program_Hide|#PB_Program_Open|#PB_Program_Read|#PB_Program_Error)
  If Exe
    While ProgramRunning(Exe)
      WindowEvent()
      If AvailableProgramOutput(Exe)
        Output$=ReadProgramString(Exe)
        error$ = ReadProgramError(Exe)
        name$ = StringField(Output$,1,"  ")
        If FindString(Output$,"|") = 0
          If FindString(Output$,"----") = 0
            n + 1
            prog$(n) = RTrim(Output$)
          EndIf
        EndIf
        Debug Output$ ; comment this line to see  no  error  line output
        If error$
          Debug error$
        EndIf
      EndIf
    Wend
    CloseProgram(exe)
  EndIf
  For z = 1 To n
    s$ = Trim(Mid(prog$(z),102,12)) ; test for new  version
    If s$
      update$(z,0) = RTrim(Mid(prog$(z),1,41))  ;NAME
      update$(z,1) = s$                         ;NEW VERSION
      update$(z,2) = RTrim(Mid(prog$(z),83,19)) ;CURRENT VERSION
                                                ;Debug update$(z,0) + "  " + update$(z,1) + "  " + update$(z,2)
      AddGadgetItem(0, -1, update$(z,0) + "  " + update$(z,1) + "  " + update$(z,2))
    EndIf
    WindowEvent()
    s$ = ""
  Next z
  ; more processng follows here but not required  to see results from above.
  Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
- - - - - - - - - - - - - - - -
Randy
I *never* claimed to be a programmer.
Randy Walker
Addict
Addict
Posts: 1109
Joined: Sun Jul 25, 2004 4:21 pm
Location: USoA

Re: [Abandoned effort] RunProgram Reading Between The Lines

Post by Randy Walker »

I was aiming at a Very simple GUI interface for the Windows "winget" CLI utility but cannot get runprogram to cooperate for me. So,I went in search on the web to see if anyone else had beat me to it. Well, Its out there but it's not a simple GUI. It's chalk full of wizzdings to the point I have no idea what's happening. Find it here if you're interested:
https://www.marticliment.com/unigetui/
- - - - - - - - - - - - - - - -
Randy
I *never* claimed to be a programmer.
AZJIO
Addict
Addict
Posts: 2223
Joined: Sun May 14, 2017 1:48 am

Re: [Abandoned effort] RunProgram Reading Between The Lines

Post by AZJIO »

Call the Win+R hotkey and check the line's operation

Code: Select all

powershell.exe -NoExit winget list
I'm getting a message that winget doesn't exist
Randy Walker
Addict
Addict
Posts: 1109
Joined: Sun Jul 25, 2004 4:21 pm
Location: USoA

Re: [Abandoned effort] RunProgram Reading Between The Lines

Post by Randy Walker »

AZJIO wrote: Sat Mar 08, 2025 1:57 am Call the Win+R hotkey and check the line's operation

Code: Select all

powershell.exe -NoExit winget list
I'm getting a message that winget doesn't exist
Yes, I came across a comment somewhere telling winget is not standard on all Windows 11, but can get it in the "Microsoft store". Mine came with it, and works fine.
- - - - - - - - - - - - - - - -
Randy
I *never* claimed to be a programmer.
Post Reply