Page 1 of 1

RunProgram - prevent messagebox from appearing?

Posted: Sun Jun 13, 2010 2:06 pm
by Nituvious
Whenever you type an invalid executable or path with RunProgram on windows, you get a messagebox that appears "Windows cannot find '....'. Make sure you typed the name correctly, and then try again."
How can we prevent this run popping up? It halts my program until the annoying box is closed..

Re: RunProgram - prevent messagebox from appearing?

Posted: Sun Jun 13, 2010 2:17 pm
by datachild
Check first if the file is there/exists before try to run anything ...
:)

Re: RunProgram - prevent messagebox from appearing?

Posted: Sun Jun 13, 2010 2:26 pm
by DarkPlayer
Hello,

For Windows just use the CreateProcess() API.

Example:

Code: Select all

StartInfo.STARTUPINFO 
StartInfo\cb = SizeOf(STARTUPINFO)
ProcessInfo.PROCESS_INFORMATION 

If CreateProcess_("404.exe",0,0,0,0,0,0,0,@StartInfo, @ProcessInfo)
  Debug "started"
Else
  Debug "Not started :-("
  If GetLastError_() = 2
    Debug "File not found!"
  EndIf
EndIf
Replace the 404.exe with C:\windows\notepad.exe and it should start Notepad.

The Documentation for CreateProcess(): http://msdn.microsoft.com/en-us/library ... 85%29.aspx

DarkPlayer

Re: RunProgram - prevent messagebox from appearing?

Posted: Sun Jun 13, 2010 4:02 pm
by Edwin Knoppert
>you get a messagebox that appears "Windows cannot find '....'.
You're not kidding me heh?
Is this an action made by the compiler?

Re: RunProgram - prevent messagebox from appearing?

Posted: Sun Jun 13, 2010 4:35 pm
by netmaestro
Why not just:

Code: Select all

If FileSize(path$) > 0
  RunProgram([..])
EndIf

Re: RunProgram - prevent messagebox from appearing?

Posted: Sun Jun 13, 2010 6:24 pm
by Nituvious
Thanks guys, I'm kind of "not all there" when it comes to programming. So the simplest tasks to you guys is a whole another country to me. :(