Jump to content

Task Scheduler Issue


Recommended Posts

Hello Good day!

I would like to ask help and know what is causing the problem.

I currently have 3 files named Backup.au3, Setter.au3 and Sample.ini . If i manually click on these files they run just fine without problems.

The problem comes when i run Backup.au3.the program seems to run but in a suspended state and consumes alot off CPU and RAM if not forcefully ended. As for the Setter.au3 Task Scheduler has no issues with it

 

Code for Backup.au3. Any suggestions and help is appreciated 

Opt("TrayAutoPause", 0)

Local $time = _NowTime(5)
Local $date = _NowDate()
Local $return


$date = StringReplace($date, "/", "-")
$time = StringReplace($time, ":", "-")

Local $DateTime = $date &" "& $time
Local $test = String ($DateTime)

Local $loc = IniRead ("Sample.ini", "Direct", "BackUpLocation", "" )    ;to be backed up   also \ to exclude the base folder
Local $to = IniRead ("Sample.ini", "Direct", "BackUpDirectory", "" )    ;folder location for the backup to be saved


$loc = $loc & "\"
$to = $to & "\"
$try = $to &""& $test
$try = String($try)

RunWait(@ComSpec &  ' /c ""%ProgramFiles%\WinRAR\Rar.exe" a -ep1 -r -y "'&$try&'" "'&$loc&'" "',"", @SW_HIDE)

_Notify_Show(@AutoItExe, "Backup Succesfull", "Retracts after 5 secs", 5, 0)
Sleep(5000)

Exit

The ini file is used to store the location to be backed up.

Link to comment
Share on other sites

1 hour ago, BlackSnoww said:

both au3 and exe wont run.

How do you determine they're not running? What credentials is the task running under, in other words are you running it under the System account, or the logged in user's account? If it's not set to interactive, it won't show anything due to it running in Session 0, which is hidden from the interactive session (anything higher than session 0)

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

Link to comment
Share on other sites

14 minutes ago, BrewManNH said:

How do you determine they're not running? What credentials is the task running under, in other words are you running it under the System account, or the logged in user's account? If it's not set to interactive, it won't show anything due to it running in Session 0, which is hidden from the interactive session (anything higher than session 0)

The program is partially running because i can see the program icon on the taskbar beside the clock running but the Backup file is not being created on the specified location. The program also slowly eats the CPU and RAM usage if not forcefully ended through the task manager.

My computer has only one account named "localuser" and checked the box on the task scheduler which says run through the Highest privilege.

The only thing i cant understand is why does the program work when i manually click it and run it while if i use Task scheduler to run it it doesnt fully execute.

Link to comment
Share on other sites

Where is the program saving to? If it's a mapped network drive, and you're using its drive letter, try using the UNC path 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

Link to comment
Share on other sites

I'll ask it again, where is it saving to?

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

Link to comment
Share on other sites

1 minute ago, BrewManNH said:

I'll ask it again, where is it saving to?

the program reads it from an ini file while contains these data

 

[Direct]
BackUpLocation=C:\Users\localuser\Desktop\Pinnger
BackUpDirectory=C:\Users\localuser\Desktop\Sample Backup location

 

Link to comment
Share on other sites

Here the code I used to test.  Working fine.  Win7. Compiled x86.  Schedule every day.

#AutoIt3Wrapper_Change2CUI=y
#include <Date.au3>

Opt("TrayAutoPause", 0)

Local $time = _NowTime(5)
Local $date = _NowDate()
Local $return


$date = StringReplace($date, "/", "-")
$time = StringReplace($time, ":", "-")

Local $DateTime = $date &" "& $time

Local $loc = "C:\Apps\Mirc\*.*"
Local $to = "C:\Apps\Temp\" & $DateTime

RunWait (@ComSpec & ' /c  ""%programfiles(x86)%\WinRAR\Rar.exe" a -ep1 -r -y "' & $to & '" "' & $loc & '"',"")
if @error then Exit

TrayTip ("WinRAR", "Backup completed", 10, 1)

Sleep (5000)

Notice I remove the extra " at the end of the runwait...

Link to comment
Share on other sites

Use consolewrite to see if the variables contain the information  you think they are supposed to. Don't hide the process that you're running, get rid of the "/c" and the @SW_HIDE until you've troubleshot the issue.

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

Link to comment
Share on other sites

32 minutes ago, Nine said:

Here the code I used to test.  Working fine.  Win7. Compiled x86.  Schedule every day.

#AutoIt3Wrapper_Change2CUI=y
#include <Date.au3>

Opt("TrayAutoPause", 0)

Local $time = _NowTime(5)
Local $date = _NowDate()
Local $return


$date = StringReplace($date, "/", "-")
$time = StringReplace($time, ":", "-")

Local $DateTime = $date &" "& $time

Local $loc = "C:\Apps\Mirc\*.*"
Local $to = "C:\Apps\Temp\" & $DateTime

RunWait (@ComSpec & ' /c  ""%programfiles(x86)%\WinRAR\Rar.exe" a -ep1 -r -y "' & $to & '" "' & $loc & '"',"")
if @error then Exit

TrayTip ("WinRAR", "Backup completed", 10, 1)

Sleep (5000)

Notice I remove the extra " at the end of the runwait...

I tried ur code and modified the locations to run in my computer. It seems rar.exe cant see the files i want it to Compress

#AutoIt3Wrapper_Change2CUI=y
#include <Date.au3>

Opt("TrayAutoPause", 0)

Local $time = _NowTime(5)
Local $date = _NowDate()
Local $return


$date = StringReplace($date, "/", "-")
$time = StringReplace($time, ":", "-")

Local $DateTime = $date &" "& $time

;Local $loc = "C:\Apps\Mirc\*.*"
;Local $to = "C:\Apps\Temp\" & $DateTime

Local $loc = "C:\Users\localuser\Desktop\Pinnger\"
Local $to = "C:\Users\localuser\Desktop\Sample Backup location\" & $DateTime


RunWait (@ComSpec & ' /k  ""%ProgramFiles%\WinRAR\Rar.exe" a -ep1 -r -y "' & $to & '" "' & $loc & '"',"")
if @error then Exit

TrayTip ("WinRAR", "Backup completed", 10, 1)

Sleep (5000)

Here is the CMD error

Untitled.jpg

Edited by BlackSnoww
wrong terminology it should be Compress not extract
Link to comment
Share on other sites

1 hour ago, Nine said:

Here the code I used to test.  Working fine.  Win7. Compiled x86.  Schedule every day.

#AutoIt3Wrapper_Change2CUI=y
#include <Date.au3>

Opt("TrayAutoPause", 0)

Local $time = _NowTime(5)
Local $date = _NowDate()
Local $return


$date = StringReplace($date, "/", "-")
$time = StringReplace($time, ":", "-")

Local $DateTime = $date &" "& $time

Local $loc = "C:\Apps\Mirc\*.*"
Local $to = "C:\Apps\Temp\" & $DateTime

RunWait (@ComSpec & ' /c  ""%programfiles(x86)%\WinRAR\Rar.exe" a -ep1 -r -y "' & $to & '" "' & $loc & '"',"")
if @error then Exit

TrayTip ("WinRAR", "Backup completed", 10, 1)

Sleep (5000)

Notice I remove the extra " at the end of the runwait...

May i ask why that quote is an extra ? Doesnt it balance the double quote found after the /c ?

RunWait (@ComSpec & ' /c  ""%ProgramFiles%\WinRAR\Rar.exe" a -ep1 -r -y "' & $to & '" "' & $loc & '" ',"")

 

Im still currently figuring out why the "?" is added at the end of the file name

Link to comment
Share on other sites

Try it this way.

RunWait(@ComSpec & ' /c  "%programfiles(x86)%\WinRAR\Rar.exe" a -ep1 -r -y "' & $to & '" "' & $loc & '"', "")

You have 2  double quotes before the %programfiles(x86)%, you only need one.

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

Link to comment
Share on other sites

6 hours ago, BlackSnoww said:

May i ask why that quote is an extra ? Doesnt it balance the double quote found after the /c ?

Because when there is a space somewhere along the path to the exe, it doesn't work if I don't have the starting 2 double quotes.  cmd.exe says that it cannot run the program (it stops at the first space it found).  It's like the first double quote was eaten by the run* function.  Might be a bug, idk.  I'm always trying first with a single double quote, and if it doesn't work, I add a second one and it is working fine then.  I thought you were facing the same problem as I have...

Edited by Nine
Link to comment
Share on other sites


I figured out where is the problem. I tried hard coding the directories in my Backup.au3 and it works perfectly on the task scheduler.

But if i read the Directories from a ini file it wont run. Now i think the task scheduler has issues with my program because if i run the backup.au3 using it it cant find the ini file which is on the same directory but if i manually click the backup.au3 it works like a charm.

 

Anyone has idea why it cant read from the ini file if executed

using task scheduler ?

 

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...