Sign in to follow this  
Followers 0
hispeed_mike

@error - Understanding the logic - Quick Help needed

5 posts in this topic

Hi,

I have a script which runs sends a command to a command line and then moves on to the next command.

What I want to do is to run it and get feedback on the completion if it encountered and error. So I looked up the @error. A quick outline of what I did is below.... Quic help to understand how the error value is set will help me get to where I am Going....

#include "Process.au3"

Opt("RunErrorsFatal", 1)

$netsh1 = RunWait (@ComSpec & " /c " & 'cacls "c:\Program Files\CB" /e /t /c /p "Inet":F', "", @SW_SHOW)

If netsh1 = @error Then

FileWriteLine (@DESKTOPDIR & "\SetupLog.txt", "Failed to set permissions on the xx folder - Set Permissions manually by turning off Simple File sharing and set permissions to Users with Full Access Privileges")

EndIf

The issue I am getting is the command runs successfully and it still writes the error to the log file. My logic is all wrong and needs straightening out....

Thanks for your help....

Mike

Share this post


Link to post
Share on other sites



If @error Then
     FileWriteLine (@DESKTOPDIR & "\SetupLog.txt", "Failed to set permissions on the xx folder - Set Permissions manually by turning off Simple File sharing and set permissions to Users with Full Access Privileges")
EndIf

maybe not sure

Share this post


Link to post
Share on other sites

If @error Then
     FileWriteLine (@DESKTOPDIR & "\SetupLog.txt", "Failed to set permissions on the xx folder - Set Permissions manually by turning off Simple File sharing and set permissions to Users with Full Access Privileges")
EndIf

maybe not sure

I did try the removal of the @error = 1 but still got the same effect....Any other ideas

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

im just throwing ideas out not really sure if it will work or if it will do any thing at all

Opt("RunErrorsFatal", 0)

try that i guess

it says in the help file that will set @error to 1 if it fails

and instead of just If @error you could try If @error = 1 it really shouldnt effect it but its not gonna hurt

Edited by narayanjr

Share this post


Link to post
Share on other sites

im just throwing ideas out not really sure if it will work or if it will do any thing at all

Opt("RunErrorsFatal", 0)

try that i guess

it says in the help file that will set @error to 1 if it fails

and instead of just If @error you could try If @error = 1 it really shouldnt effect it but its not gonna hurt

It still writes an error if it completed successfully....Strange...This would mean that the @error always equals the commands outcome??????????

I tried setting the RunErrorsFatal to 1 and 0, and also @error=1 or @error=0. Still no dice....do I just give it up as too hard...I really need to make sure I get a succes or failure ont he command....

Also tried If $netsh1 = @error...still same result.

Is there any other way?

Thanks

Mike

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