Page 1 of 1

[Abandoned effort] RunProgram Reading Between The Lines

Posted: Tue Mar 04, 2025 3:55 am
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.

Re: RunProgram Reading Between The Lines

Posted: Tue Mar 04, 2025 7:58 am
by infratec
Try to read the error output too.

Re: RunProgram Reading Between The Lines

Posted: Tue Mar 04, 2025 10:07 am
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.

Re: RunProgram Reading Between The Lines

Posted: Tue Mar 04, 2025 10:13 am
by BarryG
The flag on its own isn't enough. You need to use ReadProgramError() as well, which isn't there.

Re: RunProgram Reading Between The Lines

Posted: Tue Mar 04, 2025 10:17 am
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 !!!

Re: RunProgram Reading Between The Lines

Posted: Tue Mar 04, 2025 9:13 pm
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$

Re: RunProgram Reading Between The Lines

Posted: Tue Mar 04, 2025 10:06 pm
by BarryG
It might be, but we don't have your full snippet to see.

Re: RunProgram Reading Between The Lines

Posted: Tue Mar 04, 2025 11:35 pm
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

Re: [Abandoned effort] RunProgram Reading Between The Lines

Posted: Fri Mar 07, 2025 11:38 pm
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/

Re: [Abandoned effort] RunProgram Reading Between The Lines

Posted: Sat Mar 08, 2025 1:57 am
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

Re: [Abandoned effort] RunProgram Reading Between The Lines

Posted: Sat Mar 08, 2025 2:14 am
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.