eRIZ Posted March 15, 2011 Share Posted March 15, 2011 Hi!I've written simple script for getting newest backup created by DirectAdmin:#include <Constants.au3> Local $foo = Run("plink user@host ""ls -t /catalog/with/backups | head -n 1""", "", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) Local $line While 1 $line &= StdoutRead($foo) If @error Then ExitLoop Wend $line = StringTrimRight($line, 1) MsgBox(1, "title", $line) $o = Run("E:\\bin\\pscp -C user@host:/catalog/with/backups/" &$line & " " &$line, "E:\\backups")It works very well if executed normally (eg. double click on script). But something goes wrong if it's executed by Windows7 Task Scheduler. Nevetherless permissions - system or of my account; tried to use compiled version of scripts - no change.I tried to find out what's coming on.The process tree started by Task Scheduler freezes for some, unknown reason. It looks like this:and they don't stop... Any ideas how resolve this problem?Cheers,eRIZ Link to comment Share on other sites More sharing options...
water Posted March 15, 2011 Share Posted March 15, 2011 (edited) IIRC the task scheduler runs the program with the permissions you specify. But the environment a user gets when he logs on by the login script is not available to the program started by the task scheduler. Try to replace drive letters by UNC paths (\\Servername\share\path). I'm not sure what it needs to let the task scheduler place something on the desktop (MsgBox etc.). Do yourself a favour and put some error checking in your script. Check @error after the run and statements and write error messages to a log if @error <> 0. Edited March 15, 2011 by water My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
eRIZ Posted March 16, 2011 Author Share Posted March 16, 2011 IIRC the task scheduler runs the program with the permissions you specify. But the environment a user gets when he logs on by the login script is not available to the program started by the task scheduler.I wrote I tried on different permissions.Try to replace drive letters by UNC paths (\\Servername\share\path).Okay, but application is correctly executed, what does the path matter here?I'm not sure what it needs to let the task scheduler place something on the desktop (MsgBox etc.).Oh, I forgot - I added MsgBox for debug purposes.Do yourself a favour and put some error checking in your script. Check @error after the run and statements and write error messages to a log if @error <> 0.How can I pass through the error checking if the code after Wend isn't executed? Link to comment Share on other sites More sharing options...
water Posted March 16, 2011 Share Posted March 16, 2011 Okay, another try. Let's say you interactively logon to user xyz. The logon script assigns UNC path \\server\share\path as drive D:\ If user xyz has the needed permissions he can access files residing on this drive. If the task scheduler runs a task with the permission of user xyz there is no D:\ drive, just the permissions to access files on \\server\share\path. So you can either access a file using UNC notation or assign the UNC path to a drive yourself in your script. Okay, but application is correctly executedThat's something you didn't mention in your first post. Error checking means: Check if an action you started finished without errors. You start a program and then wait for some output of this program. If the start of the program wasn't successful you will wait forever, right? So please insert lineIf @error <> 0 then FileWriteLine("C:\temp\log.txt", "run of ... ended with @error " & @error) My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now