Jump to content
Sign in to follow this  
tom1126

PuTTY and Windows task scheduler

Recommended Posts

tom1126

Hey everyone,

I'm trying to set up a script to run every 4 hours via windows task scheduler. The script works fine when I run it on my own, however when I try to start it with windows task scheduler the script starts fine, but it does not make the opening putty screen active.

The first two lines of the code open putty, then I use WinWaitActive("PuTTY Configuration"). It seems like it's not registering that winwaitactive command. I can click the putty configuration window to make it active, then it will execute the code. Any idea what's going on here?

Share this post


Link to post
Share on other sites
BrewManNH

http://www.autoitscript.com/wiki/FAQ#Why_doesn.27t_my_script_work_on_a_locked_workstation.3F


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
tom1126

Okay, I've tried WinWait and I'm still getting a similar result, except now it seems to initiate the tabs on the desktop and open a random folder I have on there. Here's the first few lines of the code where the problems are happening.

$Log = 0
Do
run("C:\Users\Tommy\Desktop\putty.exe");run putty
Sleep(5000)
WinWait("[CLASS:PuTTYConfigBox]")
;WinWaitActive("PuTTY Configuration") ;make opening screen active
sleep(1000) ;pause for 1 second

$Log = 1 + $Log
send("{TAB 4}") ;presses tab 4 times to get to saved session
$downMotion = $Log + 1
send("+{DOWN "&$downMotion&"}") ;goes down from default to the first saved session
send("{ENTER}") ;launches session
Edited by tom1126

Share this post


Link to post
Share on other sites
BrewManNH

Did you read the whole link I posted? Because it tells you that you can't use Send either, use ControlSend. There are also several example scripts showing how to use putty with AutoIt, check the Example Scripts section.


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
tom1126

Thanks a lot BrewMan! The ControlSend got it to work.

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  

×