in reply to Prevent windows dialog when using file test -e

You can control the display of error dialogs through the API SetErrorMode(). Using Win32::API::Prototype it looks like this. See the link for possible values of the argument and note that they are bit flags that can be or'd together.

#! perl -slw use strict; use Win32::API::Prototype; ApiLink( 'Kernel32', q[ UINT SetErrorMode( UINT uMode ) ] ); SetErrorMode( 0x8000 ); ## Updated per ikegami's correction below. if( -e $ARGV[ 0 ] ) { print 'Found it?' } else { print 'Not found'; }

Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

Replies are listed 'Best First'.
Re^2: Prevent windows dialog when using file test -e
by Outaspace (Scribe) on Jun 22, 2006 at 11:47 UTC
    Thanks that was a good hint,

    I use Win32::API instead and the uMode 8 doesnt fix my problem. Until now I have to use :
    if ($^O eq 'MSWin32') { require Win32::API; Win32::API->Import('Kernel32','SetErrorMode','I','I'); print "Disable :".SetErrorMode(0x0001)."\n"; }
    Seems that 8 is something else. With 1 I can surpress the "Drive not ready dialog"

      He might have meant 0x8000. If 0x8000 works, I'd use that. Using 0x0001 could disable more than you intend to disable.

      Reference: SetErrorMode

        ikegami++ Corrected.


        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
        "Science is about questioning the status quo. Questioning authority".
        In the absence of evidence, opinion is indistinguishable from prejudice.
        Yes but Mode 0x8000 didn't disable the "Drive not ready" on my machine. Is there a Mode that only disable this Dialog ?