dumbledor Posted June 7, 2012 Posted June 7, 2012 Hello. I prepared a script to work on my computer every night and i tried to run it with scheduled task in windows Vista. It runs and scheduled task manager gives me positive feedback. But script doesn't work. It runs every msgbox but doesn't want to open file. If i run it myself it works, but if scheduled task runs it doesn't open file. MsgBox(0, "", "Pred odpiranjem filetka") $log = FileOpen("C:\log.txt", 10) MsgBox(0, "", "Za odpiranjem pred pisanjem") FileWriteLine ($log, "****************************"&@YEAR&"-"&@MON&"-"&@MDAY&" ob "&@HOUR&":"&@MIN&":"&@SEC&"******************************************") MsgBox(0, "", "Po pisanju") Filewriteline ($log, "") MsgBox(0, "", "Pred pisanjem") FileClose($log) MsgBox(0, "", "Za zapiranjem") Any help? Any ideas? Thanks in advanced. Dumbledor
Kidney Posted June 7, 2012 Posted June 7, 2012 you r opening the file to create if it doesnt exist and then erase what was in it everytime you write to it. since your last line is "", the file will be filed with nothing. you probably want mode 9 which will append to the end of the file and not write over anything.
dumbledor Posted June 7, 2012 Author Posted June 7, 2012 you r opening the file to create if it doesnt exist and then erase what was in it everytime you write to it. since your last line is "", the file will be filed with nothing. you probably want mode 9 which will append to the end of the file and not write over anything.That is not the problem i know what 10 means. Script doesn't create file or change it when i run script in schudled task.
BrewManNH Posted June 7, 2012 Posted June 7, 2012 You can't use msgbox in a scheduled task. You'll never see it, and there's no timeout on them so the task is probably running with a hidden msgbox on your system. Take out anything that requires someone to click off the message boxes. 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 GudeHow 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
dumbledor Posted June 8, 2012 Author Posted June 8, 2012 I used MsgBox just for checking if script works. And funny thing is that i get msg from box and i can read it and click it, but file is not opened and saved. Any ideas?
BrewManNH Posted June 8, 2012 Posted June 8, 2012 What credentials is the task running under? Try writing to a less protected area than the root of the C: drive, especially in Vista/7. Put in some error checking to see what is happening and where it's failing. Get rid of the message boxes for the scheduled task. That's all I can think of right now off the top of my head. You need to find out why it's failing, and then correct the problem. 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 GudeHow 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
dumbledor Posted June 18, 2012 Author Posted June 18, 2012 I will try, what you suggested. I was abroad for one week. I will report the results. Thank you for helping. Dumbledor
dumbledor Posted July 27, 2012 Author Posted July 27, 2012 Ok. I prepared example. This code creates log.txt file reads from tester.txt and then creates file test-exe.txt. It runs great if i run it. If i run schudled task in Vista the task is running and nothing happens. Any ideas? Dumbledor Attachment: tester.au3 tester.exe tester.txt tester.iniforum.zip
BrewManNH Posted July 27, 2012 Posted July 27, 2012 I can't open the zip file, says it's not a valid zip format. 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 GudeHow 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
Zedna Posted August 2, 2012 Posted August 2, 2012 Look here http://www.autoitscript.com/wiki/FAQ#Why_doesn.27t_my_script_work_on_a_locked_workstation.3F Resources UDF ResourcesEx UDF AutoIt Forum Search
dumbledor Posted August 6, 2012 Author Posted August 6, 2012 I already read that and i didn't use any of functions there. I researched forum and didn't find answer. My code: expandcollapse popup#cs ---------------------------------------------------------------------------- AutoIt Version: 3.3.8.1 Author: myName Script Function: Template AutoIt script. #ce ---------------------------------------------------------------------------- ; Script Start - Add your code below here #include <File.au3> #include <Array.au3> ;Do ;if (@HOUR = 20) Then $log = FileOpen("log.txt", 9) FileWriteLine ($log, "****************************"&@YEAR&"-"&@MON&"-"&@MDAY&" ob "&@HOUR&":"&@MIN&":"&@SEC&"******************************************") Filewriteline ($log, "") ;prebere vrednosti iz ini $branje_pot = IniRead("tester.ini", "section", "branje_pot", "NotFound") If $branje_pot = "NotFound" Then FileWriteLine($log, $branje_pot) Exit EndIf $pisanje_datoteke = IniRead("tester.ini", "section", "pisanje_datoteke", "NotFound") If $pisanje_datoteke = "NotFound" Then FileWriteLine($log,"Error reading ini file 4/4.") Exit EndIf FileWriteLine($log, "Reading ini - OK") $file = FileOpen($branje_pot, 0) $file2 = FileOpen($pisanje_datoteke, 10) If $file = -1 Then FileWriteLine($log,"No Files Found1.") Exit EndIf If $file2 = -1 Then FileWriteLine($log,"No Files Found2.") Exit EndIf FileWriteLine($file2, "test") FileWriteLine($file2, "") Local $line = FileReadLine($file, 2) FileWriteLine($file2, $line) FileClose($file2) FileClose($file) FileWriteLine($log,"Zaprti datumi.") FileClose($log) My tester.ini file: [section] branje_pot=tester.txt pisanje_datoteke=test-exe.txt
tes5884 Posted August 6, 2012 Posted August 6, 2012 If you look you'll see I had what I believe is a similar issue. It was solved with the help of BrewManNH by placing the script in a folder on the root drive ©. I believe the issue was somehow a permission thing.My apologies if I misunderstood your question. www.tspitz.com
dumbledor Posted August 8, 2012 Author Posted August 8, 2012 Thanks for answering, but i already tried that and it doesn't work. I read your article.
BrewManNH Posted August 8, 2012 Posted August 8, 2012 One suggestion I can think of is to not use relative paths to the files. Use the full path name and file name instead. It's quite possible that the task can't find the files where it thinks they are. 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 GudeHow 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
dumbledor Posted October 11, 2012 Author Posted October 11, 2012 Already tried that. Anbody got any idea, i have a lot of procedures written in Delphi, i like autoit more, so i would be delighted if this could work. Thanks for trying to help me i appriciated.
ripdad Posted October 11, 2012 Posted October 11, 2012 ; From: tester.ini ; [section] ; branje_pot=tester.txt ; pisanje_datoteke=test-exe.txt ; 1) Does the file exist? ; 2) Where? In the same folder as your script or another folder? If Not FileExists($branje_pot) Then MsgBox(0, '', 'File Not Found!') Exit EndIf ; Maybe works better with Full Path... ; [section] ; branje_pot=C:MyTestFoldertester.txt ; pisanje_datoteke=C:MyTestFolderAnotherFoldertest-exe.txt "The mediocre teacher tells. The Good teacher explains. The superior teacher demonstrates. The great teacher inspires." -William Arthur Ward
dumbledor Posted December 25, 2012 Author Posted December 25, 2012 (edited) ; From: tester.ini ; [section] ; branje_pot=tester.txt ; pisanje_datoteke=test-exe.txt ; 1) Does the file exist? ; 2) Where? In the same folder as your script or another folder? If Not FileExists($branje_pot) Then MsgBox(0, '', 'File Not Found!') Exit EndIf ; Maybe works better with Full Path... ; [section] ; branje_pot=C:MyTestFoldertester.txt ; pisanje_datoteke=C:MyTestFolderAnotherFoldertest-exe.txt 1. Yes it exists 2. No. In network drive. Tried full path that doesn't make a difference. Any ideas? Edited December 25, 2012 by dumbledor
Thatusernameisalreadytaken Posted December 25, 2012 Posted December 25, 2012 I prepared a script to work on my computer every night and i tried to run it with scheduled task in windows Vista. It runs and scheduled task manager gives me positive feedback. But script doesn't work.I've got the same issue with Vista x64, user having administrative privileges, also tested with UAC on/off.I've never had any luck with running any scheduled compiled script, even the simplest one like "open a file - write a line - close the file". Played about 2 days with it and finally gave up - Vista always says that the task has begun but it's a lie actually.I've just looped my script to run endlessly and check for some particular time to update. It takes only a couple of lines of code.Anyway I'll be glad to have a solution with windows scheduler too
Solution dumbledor Posted August 1, 2014 Author Solution Posted August 1, 2014 I finally found the stupid solution. it took me 2 years. I did other things too. OK here it goes. All you have to do is put the path to program in Start in (optional). I also did this, maybe is need: You should grant to the specified user access to COM automation factory: 1) Start->Run->dcomcnfg 2) Component Services->Computers->My Computer 3) Right-click My Computer, Properties 4) COM Security tab, Launch and Activation Permissions, Edit Default 5) Add all access rights for the specified user, you are using to run scheduled task. Hope it helps. Please replay if it is working for you. pacific and Neutro 1 1
Recommended Posts