Using Windows Command Line

77 views
Skip to first unread message

lawrence....@gmail.com

unread,
Jun 15, 2025, 9:49:31 PM6/15/25
to Harbour Minigui
Hi all just wondering how I can run a windows batch file from MiniGui and Harbour, is there a way to run ie shell out of the app and run this

Grigory Filatov

unread,
Jun 16, 2025, 3:42:07 AM6/16/25
to Harbour Minigui
Hi,

Thanks for your request.

 Here is a complete working example of a Harbour MiniGUI application that runs a batch file (mybatch.bat) using the ShellExecute() function:

 #include "minigui.ch"

Function Main

   DEFINE WINDOW Win_1 ;
      AT 0,0 ;
      WIDTH 400 ;
      HEIGHT 200 ;
      TITLE 'Run Batch File Example' ;
      MAIN

      @ 60, 100 BUTTON Btn_RunBatch ;
         CAPTION "Run mybatch.bat" ;
         WIDTH 200 ;
         ACTION RunMyBatch()

   END WINDOW

   ACTIVATE WINDOW Win_1

Return Nil

Function RunMyBatch

   LOCAL cBatchFile := "mybatch.bat"

   IF FILE( cBatchFile )
      ShellExecute( 0, "open", cBatchFile, "", "", 1 )
      MsgInfo( cBatchFile + " has been executed.", "Info" )
   ELSE
      MsgStop( "Batch file not found: " + cBatchFile, "Error" )
   ENDIF

Return Nil

Notes:
  • Place a mybatch.bat file in the same directory as the EXE.

  • Adjust the batch filename path if it's located elsewhere.

  • ShellExecute() handles .bat execution as if double-clicked in Windows Explorer.

Hope this is helpful.

Regards,
Grigory

понедельник, 16 июня 2025 г. в 03:49:31 UTC+2, lawrence....@gmail.com:
Reply all
Reply to author
Forward
0 new messages