Sign in to follow this  
Followers 0
ShipUPride

AutoItSetOption in Windows 2000 with VBS

3 posts in this topic

#1 ·  Posted (edited)

In order to solve (band-aid) a problem we are having on a server, we are using the script below to run as a scheduled task, look for a pop-up error, and respond to it by hitting ENTER (OK button) to clear the error so the application will continue to process.

I have created a test pop-up that simulates the error we get on the server.

MsgBox "Click OK To Close Me",0,"Communication with AS400 Version 1.35"
MsgBox "Click OK To Close Me",0,"as400"

Window Title: Communication with as400... is the production application window

Window Title: as400... is the error prompt that pops up.

The problem is, when I run both scripts (first the test prompt script and secondly the script to respond to the test prompt), I get different results on my production server than I do on my laptop. My laptop is running XP SP2 while my server is running Windows 2000 SP 4.

When I run it on XP, the script works perfectly as you would expect it to. It looks for the pop-up with the EXACT TITLE I am looking for, and closes it, while ignoring the title that simply contains 1 of the terms.

In 2000, however, when the error pop-up is on screen, it works perfectly. But as a scheduled task, it often runs when there is no error, in which case it should simply quit. Instead it ignores the EXACT TITLE option and attempts to hit ENTER on the wrong window.

Can anyone offer any suggestions?

(Here is the script to detect, close the pop-up window, and write event to event log)

'Created JJWOLFER 2/8/2008 for RF Server AS400 Error Prompts
    'On Error Resume Next
    
    'Initiate WshShell and AutoIT
    Set WshShell = CreateObject("WScript.Shell") 'create WshShell object
    WshShell.Run "Regsvr32 /s C:\AutoItX3.dll ", 0, True 'register dll

    'Check to see if Prompt Exists
    Set AutoIt = CreateObject("AutoItX3.Control")
    AutoIt.AutoItSetOption "WinTitleMatchMode", 3    '1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocase
    If AutoIt.WinExists ("as400") Then
        
        'MsgBox ("as400 Window Open")
        'Write to Event Log on Error
        Const EVENT_WARNING = 1
          Set objShell = WScript.CreateObject("Wscript.Shell")
        objShell.LogEvent EVENT_WARNING,"AS400 Communication Failure!"
        'MsgBox ("as400 Communication Failure Detected, Event Written to Event Log")
        
        'Send Command to Close Prompt
        AutoIt.AutoItSetOption "WinTitleMatchMode", 3    '1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocase
        AutoIt.WinActivate ("as400")
        AutoIt.Send "{ENTER}"
        'MsgBox ("Prompt Closed")
    
    End If

    WshShell.Run "Regsvr32 /s /u C:\AutoItX3.dll ", 0, True 'unregister dll
    Set WshShell = Nothing 'delete WshShell object
    'MsgBox ("Done")
Edited by ShipUPride

Share this post


Link to post
Share on other sites



I'm getting errors with this line:

objShell.LogEvent EVENT_WARNING,"AS400 Communication Failure!"
msg: The event log file is full

Otherwise it seems to work as intended (scheduled task same usr/pwd as user logged on.

w2k-sp4 and updates.

Share this post


Link to post
Share on other sites

I'm getting errors with this line:

objShell.LogEvent EVENT_WARNING,"AS400 Communication Failure!"
msg: The event log file is full

Otherwise it seems to work as intended (scheduled task same usr/pwd as user logged on.

w2k-sp4 and updates.

Thank you for testing. The error you are getting is with your system I think.

It turns out that it just seems to not work on the single server I need it to work on haha. I have done a work-around.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0