Jump to content

Suppress Autoit Compiled EXE error output


mhullnc
 Share

Recommended Posts

I have an executable that is running everytime as part of our login process. I copies a screen saver to all of the local machines and updates them if there is a change in the screen saver from the network. I have it calling itself again if the local user doesn't have rights, and then launches as a user with permissions.

This happens with every user, there are approximately 4000. On vary rare occasions there is an autoit error message that states "all pipe instances are busy". Is there any way to disable the error messages built into autoit. The script has to run compiled as a username and password with rights on the domain is used.

Here is the code with username password and domain changed accordingly.

; <AUT2EXE VERSION: 3.1.1.0>

; ----------------------------------------------------------------------------

; <AUT2EXE INCLUDE-START: C:\SS\ss.au3>

; ----------------------------------------------------------------------------

; ----------------------------------------------------------------------------

;

; AutoIt Version: 3.1.0

; Author: Mark Hull mhullnc@yahoo.com

;

; Script Function:

; TO copy down screen savers to the computers based on the name of the computer. There is an INI file that is used to specify the name that you look for in

; each screen saver. You will also specify the screen saver that gets copied to the client when the name is found

;

; 11/21/05- Added the ability to rerun the script as another user if the first pass fails

; ----------------------------------------------------------------------------

; Script Start - Add your code below here

; The settings below specify the user that is used to copy files and change the registry if the logged in user fails

$User="username"; User to be used for secondary copy if the first fails

$Domain="domain"; Domain to be used for the secondary copy if the first fails

$Password="password";Password to be used for the secondary copy if the first fails

$Errorchk=0; Setting counter variable to check for errors in the script

$debug="off"

$OS=@OSVersion

$regerr="xyzzy"; Variable used to see if there is an error in changing the registry

$copyerr="xyzzy"; Variable used to see if there is an error in Copying a file

$delerr="xyzzy"; Variable used to verify a file could be deleted

if $os="WIN_NT4" or $os="WIN_ME" or $os="WIN_98" or $os="WIN_95" Then Exit

if FileExists(@Scriptdir & "\debug.txt") THen $debug="on"

If not Fileexists(@Scriptdir & "\ss.ini") THen Exit; If the ss.ini file cannot be found then abort the script, The ini file is required to process properly

$REGCHK=RegRead("HKEY_USERS\.DEFAULT\Control Panel\Desktop","SCRNSAVE.EXE")

if $REGCHK<>"%systemroot%\default.scr" Then

$regerr=Regwrite("HKEY_USERS\.DEFAULT\Control Panel\Desktop","SCRNSAVE.EXE","REG_SZ","%systemroot%\default.scr")

If $regerr="0" Then $errorchk=$errorchk+1

If $debug="on" Then MsgBox(0,"ErrorCHK=",$errorchk & " Could not change the registry")

EndIF

If fileexists(@WindowsDir & "\system32\default.scr") Then

$delerr=FileDelete(@WindowsDir & "\system32\default.scr")

if $delerr="0" Then $errorchk=$errorchk+1

If $debug="on" Then MsgBox(0,"ErrorCHK=",$errorchk & " Could not delete the file")

EndIf

;$FromPath=("\\northeastmedical.int\netlogon\SSTest\")

$frompath=IniRead(@Scriptdir & "\ss.ini","general","Frompath","ERR"); This is the path where the files will be copied from, usually in netlogon for replication purposes

$userretry=INiread(@Scriptdir & "\ss.ini","general","Userretry","ERR"); This tells the script if it should run as another user if the first pass fails

$mysaver=""; Blank variable to get set later

$defaultname=Iniread(@Scriptdir & "\ss.ini","general","Defaultss","ERR"); Reads the INI setting for the default screen saver

;$Defaultname="default.scr"

if $debug="on" then MsgBox(0,"Data","Frompath=" & $Frompath & @crlf & "Default=" & $defaultname,10)

For $X=1 to 100; This is the maximum number of entries for specific screen savers that can be deployed, you could change the number to allow for more

$linein=INIRead(@Scriptdir & "\ss.ini","Savers","SS" & $x,"ERR"); Keep reading in the loop, when you don't see a setting and get the default ERR then exit out of the loop

if $linein="ERR" then ExitLoop; Exit loop when you get the default

$len=StringLen($Linein); pulling the two variables from the ini file

$Sep=StringinStr($linein,",")

$Name=StringLeft($Linein,$sep-1)

$Saver=StringRight($linein,$len-$sep)

if $debug="on" then MsgBox(0,"Data","Name=" & $name & @crlf & "Saver=" & $Saver,10)

if StringinStr(@Computername,$Name) Then; Checking to see if the machine gets a particular screen saver

$mysaver=$Saver; Setting the proper screen saver for the machine

ExitLoop; If the name is found, there is no need to continue checking

EndIf

Next

If $mysaver="" Then $mysaver=$defaultname; If no screen saver if found use the default

if $debug="on" then MsgBox(0,"Data","Systemdir=" & @WindowsDir & @crlf & "Saver=" & $mysaver,10)

If Not Fileexists(@WindowsDir & "\" & $defaultname) Then

$copyerr=Filecopy($Frompath & $mysaver & ".scr",@WindowsDir & "\" & $defaultname & ".scr",1)

If $copyerr="0" Then $errorchk=$errorchk+1

If $debug="on" Then MsgBox(0,"ErrorCHK=",$errorchk & " File Missing")

Else

$locsize=Filegetsize(@WindowsDir & "\" & $defaultname & ".scr")

$remsize=fileGetsize($Frompath & $mysaver & ".scr")

$locdate=Filegettime(@WindowsDir & "\" & $defaultname & ".scr",0,1)

$remdate=FileGetTime($Frompath & $mysaver & ".scr",0,1)

if $debug="on" then MsgBox(0,"Sizechk","Local=" & $locsize & @crlf & "Remote=" & $remsize,10)

if $locsize<>$remsize or $locdate<>$remdate Then

$Copyerr=FileCopy($Frompath & $mysaver & ".scr",@WindowsDir & "\" & $defaultname & ".scr",1)

If $copyerr="0" Then $errorchk=$errorchk+1

If $debug="on" Then MsgBox(0,"ErrorCHK=",$errorchk & " Could not copy the update")

EndIF

EndIf

if $Debug="on" Then MsgBox(0,"Settings", "CMDLINE=" & $CMDLINE[0] & @CRLF & "Errorcheck=" & $errorchk)

If $errorchk And $cmdline[0]="0" and $userretry="on" Then

If $debug="on" Then MSGBOX(0,"Run Again","Getting Ready to run again")

RunasSet($user,$domain,$password)

Run("\\northeastmedical.int\netlogon\ss\test\ss.exe TAKE2","",@SW_HiDE)

EndIf

exit

; ----------------------------------------------------------------------------

; <AUT2EXE INCLUDE-END: C:\SS\ss.au3>

; ----------------------------------------------------------------------------

Link to comment
Share on other sites

I look at AutoIt code and I cannot find any place where this message can be issued.

Certainly Windows do it by itself. Unless we find which AutoIt function produce the popup we cannot suppress this message.

Next time capture the popup and add it to illustrate your behavior.

Thanks B)

Link to comment
Share on other sites

Here is the actual error message in a JPEG.

Thanks for your help

:o

That's easier to help you

This message can be suppressed if you add

Opt('RunErrorsFatal',0)

to your script

B)

Edit typo correction 1->0

Edited by jpm
Link to comment
Share on other sites

That's easier to help you

This message can be suppressed if you add

Opt('RunErrorsFatal',1)

to your script

:o

In order to become aware of any other errors that might occurr... maybe it would be a good idea to put...

Opt("RunErrorsFatal", 0) ;1=fatal, 0=silent set @error (from the help file)

before the code that sometimes generates the error. Then put...

Opt("RunErrorsFatal", 1) ;1=fatal, 0=silent set @error (from the help file)

afterward.

Is there a way to check for open pipes before trying to execute the external command? (I have known this, but it escapes me for now.) Could this be indicating a network traffic issue, or a server capacity issue? In a previous work life (using a different tool), if anything failed in the login script, it generated an entry in an error log on the PC. Later during a time of historically low network traffic the error log was moved to a blind sharepoint on a server where all the error logs were processed into a daily file and analyzed for trends and immediate issues. This was very useful since users were prone to not raise issues unless they were affected daily or several were aware that they all had the same issue. We were dealing with 8500 PCs along the USA east coast, but 4000 is certainly enough to provide evidence of coming problems by the same or a similar methodology. B)

AutoIt is good at capturing the error status of virtually any operation you may use it to perform. :graduated:

Gene

[font="Verdana"]Thanks for the response.Gene[/font]Yes, I know the punctuation is not right...

Link to comment
Share on other sites

Thanks all for the help, I will try to put the RunErrorsFatal in the code tomorrow.

I am less worried about loggin the actual error, as this runs every time someone logs in. If it fails due to network traffic one time, they will simply hit it the next time they login. We have four AD domain controllers, and is running from the Netlogon share, so it is replicated and load balanced on all four servers.

Once again thanks for all the help

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...