Sign in to follow this  
Followers 0
Aapjuh

Recursion Level Exceeded

10 posts in this topic

#1 ·  Posted (edited)

Hi all,

Situation:

While running my script under UAC off everything runs fine like it should, but with UAC turned on (max) i get:

C:\Program Files\AutoIt3\Include\date.au3 (470) : ==> Recursion level has been exceeded - AutoIt will quit to prevent stack overflow.:
Local $iNumDays = _DaysInMonth($asDatePart[1])

My script: (its pretty early into the script but i cut a few things out)

#include <date.au3>
;Check Date*
Func _Aapjuh_CheckDate()
Global $ToDay = _DateToDayValue(@YEAR,@MON,@MDAY)
Global $ToDayDate = @YEAR & "/" & @MON & "/" & @MDAY
Global $ToDayTime = @HOUR & ":" & @MIN & ":" & @SEC
If FileExists($RightDir & "\Aapjuh Prog\Aapjuh-Log.txt") Then
Dim $Year, $Month, $Day
Global $WeekAgo = _DayValueToDate($ToDay-7, $Year, $Month, $Day)
Global $LogDate = FileGetTime($RightDir & "\Aapjuh Prog\Aapjuh-Log.txt", 0)
Global $LogDateValue = $LogDate[0] & "/" & $LogDate[1] & "/" & $LogDate[2]
If @WDAY = 01 Then
If $ToDayDate = $LogDateValue Then
Exit 0
Else
_Aapjuh_CheckFiles()
Endif
ElseIf @WDAY > 01 Then
If $LogDateValue < $WeekAgo Then
_Aapjuh_CheckFiles()
Else
Exit 0
EndIf
EndIf
ElseIf not FileExists($RightDir & "\Aapjuh Prog\Aapjuh-Log.txt") Then
_Aapjuh_MakeLog()
EndIf
EndFunc

The _Aapjuh_CheckDate() function doesn't get called from within other functions and is completely standalone, none of the var's are used elsewhere except for "$RightDir" which just points to a directory.

the log does not exist yet so goes through the next function and then back to _Aapjuh_CheckDate():

;Making log file*
Func _Aapjuh_MakeLog()
If not FileExists($RightDir & "\Aapjuh Prog\Aapjuh-Log.txt") Then
If FileExists("C:\Aapjuh-Log.txt") Then
FileMove("C:\Aapjuh-Log.txt", $RightDir & "\Aapjuh Prog\Aapjuh-Log.txt", 9)
Else
FileWriteLine($RightDir & "\Aapjuh Prog\Aapjuh-Log.txt", "***Aapjuh-Prog***" & @CRLF & @CRLF & "Created by: 'Aapjuh' and 'Tigo_007'" & @CRLF & @CRLF & _
"Special Thanks To: 'The creators of AutoIt' and 'The AutoIt community'" & @CRLF & @CRLF & @CRLF & "***Log:***")
FileClose($RightDir & "\Aapjuh Prog\Aapjuh-Log.txt")
FileSetTime($RightDir & "\Aapjuh Prog\Aapjuh-Log.txt", "20031101" ,0)
FileSetTime($RightDir & "\Aapjuh Prog\Aapjuh-Log.txt", "20031101" ,1)
FileSetTime($RightDir & "\Aapjuh Prog\Aapjuh-Log.txt", "20031101" ,2)
EndIf
_Aapjuh_CheckDate() ;-----------------------------------------------------------------------------------it calls the above function here again
ElseIf FileExists($RightDir & "\Aapjuh Prog\Aapjuh-Log.txt") Then
Sleep(100)
Else
_Aapjuh_ErrorMsgBox()
_Aapjuh_ErrorLogMakingLog()
EndIf
EndFunc

i dont know if the error happens before or after it goes through _Aapjuh_MakeLog().

How can i solve this? and wuts with the UAC being involved somehow..

thanks in advance,

Aapjuh

Edited by Aapjuh

Share this post


Link to post
Share on other sites



Please post a runnable script that demonstrates the problem, neither of the code snippets above can be run as is, and your other funtions are missing so there's little in the way of hints as to what you're doing wrong.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

ah k, here it is:

#include <date.au3>

Global $RightDir = "C:\Program Files"

_Aapjuh_CheckDate()

;Check Date*
Func _Aapjuh_CheckDate()
Global $ToDay = _DateToDayValue(@YEAR,@MON,@MDAY)
Global $ToDayDate = @YEAR & "/" & @MON & "/" & @MDAY
Global $ToDayTime = @HOUR & ":" & @MIN & ":" & @SEC
If FileExists($RightDir & "\Aapjuh Prog\Aapjuh-Log.txt") Then
Dim $Year, $Month, $Day
Global $WeekAgo = _DayValueToDate($ToDay-7, $Year, $Month, $Day)
Global $LogDate = FileGetTime($RightDir & "\Aapjuh Prog\Aapjuh-Log.txt", 0)
Global $LogDateValue = $LogDate[0] & "/" & $LogDate[1] & "/" & $LogDate[2]
If @WDAY = 01 Then
If $ToDayDate = $LogDateValue Then
Exit 0
Else
_Aapjuh_DoStuff()
Endif
ElseIf @WDAY > 01 Then
If $LogDateValue < $WeekAgo Then
_Aapjuh_DoStuff()
Else
Exit 0
EndIf
EndIf
ElseIf not FileExists($RightDir & "\Aapjuh Prog\Aapjuh-Log.txt") Then
_Aapjuh_MakeLog()
EndIf
EndFunc

;Making log file*
Func _Aapjuh_MakeLog()
If not FileExists($RightDir & "\Aapjuh Prog\Aapjuh-Log.txt") Then
If FileExists("C:\Aapjuh-Log.txt") Then
FileMove("C:\Aapjuh-Log.txt", $RightDir & "\Aapjuh Prog\Aapjuh-Log.txt", 9)
Else
FileWriteLine($RightDir & "\Aapjuh Prog\Aapjuh-Log.txt", "***Aapjuh-Prog***" & @CRLF & @CRLF & "Created by: 'Aapjuh' and 'Tigo_007'" & @CRLF & @CRLF & _
"Special Thanks To: 'The creators of AutoIt' and 'The AutoIt community'" & @CRLF & @CRLF & @CRLF & "***Log:***")
FileClose($RightDir & "\Aapjuh Prog\Aapjuh-Log.txt")
FileSetTime($RightDir & "\Aapjuh Prog\Aapjuh-Log.txt", "20031101" ,0)
FileSetTime($RightDir & "\Aapjuh Prog\Aapjuh-Log.txt", "20031101" ,1)
FileSetTime($RightDir & "\Aapjuh Prog\Aapjuh-Log.txt", "20031101" ,2)
EndIf
_Aapjuh_CheckDate() ;-----------------------------------------------------------------------------------it calls the above function here again
ElseIf FileExists($RightDir & "\Aapjuh Prog\Aapjuh-Log.txt") Then
Sleep(100)
Else
msgbox(0,"error", "some error")
EndIf
EndFunc

i ran test.au3 and get that error (only when UAC is on)

the date.au3 is the one from (C:Program FilesAutoitIncludeDate.au3) tried both latest stable and latest beta same error

what it does is, _Aapjuh_CheckDate to check todays date and that of the log and compare it so the var "$WeekAgo = _DayValueToDate($ToDay-7, $Year, $Month, $Day)"

if the log is older than 7 days the rest of my porgram starts, or if its sunday (which then it does _Aapjuh_DoStuff())

if theres no log file it goes to _Aapjuh_Makelog() to make a log with 11/01/2003 as its date (which is abviously more than 7 days ago ^^)

then it goes back to _Aapjuh_CheckDate to compare the newly made 'fake' log's date to todays date-7 (which is very old so it _Aapjuh_DoStuff())

if the date of the log matches todays date it exits program

Edit:

think i found the problem it keeps running "Global $ToDay = _DateToDayValue(@YEAR,@MON,@MDAY)" because the script cant make a log file cus of UAC, bleh now i gotta find a way around that, anyone know how?

test.au3

Edited by Aapjuh

Share this post


Link to post
Share on other sites

aapjuh,

Write the log to a drive/dir that does not require elevated auth.

kylomas


Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Also, if the file path doesn't exist, it won't be able to create the file either, and the problem will occur. FileWriteLine will create the file if it doesn't exist, but it will not create the path to the file if it doesn't exist.

EDIT: BTW, using this line "ElseIf Not FileExists($RightDir & "Aapjuh ProgAapjuh-Log.txt") Then" after this line "If FileExists($RightDir & "Aapjuh ProgAapjuh-Log.txt") Then" is redundant, because if the file does exist, there's no need to check later if it doesn't exist. You only need an Else statement there, because it's a binary check it either exists or it doesn't.

Edited by BrewManNH

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

aapjuh,

Write the log to a drive/dir that does not require elevated auth.

kylomas

i'd like the log in the same place as my script which is program files/aapjuh-prog, but with UAC on im not even allowed to create that dir thus failing all together

i use a script with fileinstalls in it to place 4.exe's few images and icons, the install script unpacks them into the program filesapjuh-prog dir if i do runsadmin on the install the script then runs 1 of the exe's which is the updater.exe but that updater.exe doesn't inherit the "run as admin" rights from the installer

Also, if the file path doesn't exist, it won't be able to create the file either, and the problem will occur. FileWriteLine will create the file if it doesn't exist, but it will not create the path to the file if it doesn't exist.

EDIT: BTW, using this line "ElseIf Not FileExists($RightDir & "Aapjuh ProgAapjuh-Log.txt") Then" after this line "If FileExists($RightDir & "Aapjuh ProgAapjuh-Log.txt") Then" is redundant, because if the file does exist, there's no need to check later if it doesn't exist. You only need an Else statement there, because it's a binary check it either exists or it doesn't.

the dir exists tho cus the script is already running from the dir that the log will be created in.

thnx for the elseif not part :P totaly overlooked it

damn you UAC..!! y u so evul

Edit:

how can i have ppl with UAC turned on on their pc, run my programs? most pc's i put it on so far i also freshly installed win7 on and i always turn off uac out of habit (its anoying) but friend of my uncle also wanted my program for his wifes laptop buts its UAC on.

lets say: 1 compiled script which installs 2.exe's a updater and the main program, if i manualy give them all (properties>checkbox) run as admin and a week later the update downloads the new version .exe's with the same name do they automaticly get the checkbox run as admin?

Edited by Aapjuh

Share this post


Link to post
Share on other sites

Are the users admins? If they are you could put the files in the ProgramData folder instead.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

Are the users admins? If they are you could put the files in the ProgramData folder instead.

not all of the ppl that use my program

Share this post


Link to post
Share on other sites

If they're not admins, then using "Run as administrator" isn't going to work either, because they'll need admin credentials to run it. You can always install it in their user profile folder, every user has write access to that folder. That's how Google gets around software installation restrictions with their crapware.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

If they're not admins, then using "Run as administrator" isn't going to work either, because they'll need admin credentials to run it. You can always install it in their user profile folder, every user has write access to that folder. That's how Google gets around software installation restrictions with their crapware.

oeh ye great idea nice, thanks alot

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