ATTENTION: You are viewing a page formatted for mobile devices; to view the full web page, click HERE.

Main Area and Open Discussion > General Software Discussion

WinSendKeys (Automate Task Scheduler)

<< < (2/2)

Day Agent:
Although the actual window title reads "C:\Windows\system32\schtasks.exe", the WindowName seems to be "schtasks.exe".

WinSendKeys -x schtasks -d -xp "/create /xml ""X:\task.xml"" /ru ""COMPUTER NAME\USER NAME"" /tn ""Imported Task""" schtasks.exe {ENTER}

2012-11-10 12:34:54.735, Debug logging enabled
2012-11-10 12:34:54.741, Executable Parameters specified: /create /xml "X:\task.xml" /ru "COMPUTER NAME\USER NAME" /tn "Imported Task"
2012-11-10 12:34:54.770, exename: schtasks
2012-11-10 12:34:54.774, Window: schtasks.exe
2012-11-10 12:34:54.783, Windowhandle: 0
2012-11-10 12:34:54.787, Running executable: schtasks /create /xml "X:\task.xml" /ru "COMPUTER NAME\USER NAME" /tn "Imported Task"
2012-11-10 12:34:54.948, Running executable PID: 3984
2012-11-10 12:34:55.122, Title for PID: 3984 hWND: 0x000A05BA / C:\Windows\system32\schtasks.exe
2012-11-10 12:34:55.133, Window 'C:\Windows\system32\schtasks.exe' activated.
2012-11-10 12:34:55.137, Send: {ENTER}

It works mostly but WinSendKeys can't always find the schtasks.exe window, possibly because it loads a little slow sometimes. Since a WinSendKeys Strokesfile can set WinSendKeys to wait for a window to appear, I put the following lines in a file and named it Wait.sro:

--winwait schtasks.exe 6
{ENTER}

WinSendKeys -x schtasks -xp "/create /xml ""X:\task.xml"" /ru ""COMP. NAME\USER NAME"" /tn ""Imported Task""" -f "X:\Wait.sro" schtasks.exe

Works like a charm now.

Nice program.  :)

Ath:
Although the actual window title reads "C:\Windows\system32\schtasks.exe", the WindowName seems to be "schtasks.exe".
-Day Agent (November 10, 2012, 05:55 AM)
--- End quote ---
Well, the ProcessList() function of AutoIt returns just the name of the executable, and that is what is used/checked by WSK if a Window with the specified name can not be found.

Works like a charm now.

Nice program.  :)
-Day Agent (November 10, 2012, 05:55 AM)
--- End quote ---
Thanks :)
As usual, donations are welcome :-[ (not mandatory)

Day Agent:
Although 'Window '' not found' seem to happen more infrequently, it still happens if a Strokesfile is used.
This is not due to a time-out, however. The error is thrown immediately.

2012-11-11 05:45:37.110, Debug logging enabled
2012-11-11 05:45:37.117, Executable Filepath specified: schtasks
2012-11-11 05:45:37.122, Executable Parameters specified: /create /xml "X:\Task.xml" /ru "COMPUTER NAME\USER NAME" /tn "Imported Task"
2012-11-11 05:45:37.128, Filemode, reading from file: X:\Wait.sro
2012-11-11 05:45:37.134, exename: schtasks
2012-11-11 05:45:37.139, Window: schtasks.exe
2012-11-11 05:45:37.149, Windowhandle: 0
2012-11-11 05:45:37.154, Running executable: schtasks /create /xml "X:\Task.xml" /ru "COMPUTER NAME\USER NAME" /tn "Imported Task"
2012-11-11 05:45:37.308, Running executable PID: 2344
2012-11-11 05:45:37.772, Window '' not found.
2012-11-11 05:48:42.390, Debug logging enabled
2012-11-11 05:48:42.396, Executable Filepath specified: schtasks
2012-11-11 05:48:42.402, Executable Parameters specified: /create /xml "X:\Task.xml" /ru "COMPUTER NAME\USER NAME" /tn "Imported Task"
2012-11-11 05:48:42.407, Filemode, reading from file: X:\Wait.sro
2012-11-11 05:48:42.414, exename: schtasks
2012-11-11 05:48:42.419, Window: schtasks.exe
2012-11-11 05:48:42.429, Windowhandle: 0
2012-11-11 05:48:42.434, Running executable: schtasks /create /xml "X:\Task.xml" /ru "COMPUTER NAME\USER NAME" /tn "Imported Task"
2012-11-11 05:48:42.572, Running executable PID: 3668
2012-11-11 05:48:42.861, Window '' not found.
2012-11-11 05:50:06.660, Debug logging enabled
2012-11-11 05:50:06.667, Executable Filepath specified: schtasks
2012-11-11 05:50:06.672, Executable Parameters specified: /create /xml "X:\Task.xml" /ru "COMPUTER NAME\USER NAME" /tn "Imported Task"
2012-11-11 05:50:06.689, Filemode, reading from file: X:\Wait.sro
2012-11-11 05:50:06.695, exename: schtasks
2012-11-11 05:50:06.700, Window: schtasks.exe
2012-11-11 05:50:06.709, Windowhandle: 0
2012-11-11 05:50:06.714, Running executable: schtasks /create /xml "X:\Task.xml" /ru "COMPUTER NAME\USER NAME" /tn "Imported Task"
2012-11-11 05:50:06.879, Running executable PID: 3660
2012-11-11 05:50:07.002, Title for PID: 3660 hWND: 0x001B03CA / C:\Windows\system32\schtasks.exe
2012-11-11 05:50:07.039, Window 'C:\Windows\system32\schtasks.exe' activated.
2012-11-11 05:50:07.054, --winwait schtasks.exe maxwait: 6
2012-11-11 05:50:07.070, test exename: schtasks.exe
2012-11-11 05:50:07.287, Window: schtasks.exe
2012-11-11 05:50:07.793, Windowhandle: 0x001B03CA
2012-11-11 05:50:07.798, --winwait schtasks.exe waited: 0
2012-11-11 05:50:07.804, Send: {ENTER}
2012-11-11 05:50:07.922, Send:
2012-11-11 05:50:10.269, Debug logging enabled
2012-11-11 05:50:10.275, Executable Filepath specified: schtasks
2012-11-11 05:50:10.281, Executable Parameters specified: /create /xml "X:\Task.xml" /ru "COMPUTER NAME\USER NAME" /tn "Imported Task"
2012-11-11 05:50:10.286, Filemode, reading from file: X:\Wait.sro
2012-11-11 05:50:10.292, exename: schtasks
2012-11-11 05:50:10.298, Window: schtasks.exe
2012-11-11 05:50:10.307, Windowhandle: 0
2012-11-11 05:50:10.312, Running executable: schtasks /create /xml "X:\Task.xml" /ru "COMPUTER NAME\USER NAME" /tn "Imported Task"
2012-11-11 05:50:10.621, Running executable PID: 3472
2012-11-11 05:50:10.674, Title for PID: 3472 hWND: 0x002303DC / C:\Windows\system32\schtasks.exe
2012-11-11 05:50:10.690, Window 'C:\Windows\system32\schtasks.exe' activated.
2012-11-11 05:50:10.705, --winwait schtasks.exe maxwait: 6
2012-11-11 05:50:10.721, test exename: schtasks.exe
2012-11-11 05:50:10.913, Window: schtasks.exe
2012-11-11 05:50:11.420, Windowhandle: 0x002303DC
2012-11-11 05:50:11.426, --winwait schtasks.exe waited: 0
2012-11-11 05:50:11.432, Send: {ENTER}
2012-11-11 05:50:11.573, Send:
2012-11-11 05:50:13.363, Debug logging enabled
2012-11-11 05:50:13.369, Executable Filepath specified: schtasks
2012-11-11 05:50:13.376, Executable Parameters specified: /create /xml "X:\Task.xml" /ru "COMPUTER NAME\USER NAME" /tn "Imported Task"
2012-11-11 05:50:13.383, Filemode, reading from file: X:\Wait.sro
2012-11-11 05:50:13.390, exename: schtasks
2012-11-11 05:50:13.396, Window: schtasks.exe
2012-11-11 05:50:13.406, Windowhandle: 0
2012-11-11 05:50:13.416, Running executable: schtasks /create /xml "X:\Task.xml" /ru "COMPUTER NAME\USER NAME" /tn "Imported Task"
2012-11-11 05:50:13.567, Running executable PID: 2060
2012-11-11 05:50:13.672, Title for PID: 2060 hWND: 0x002403DC / C:\Windows\system32\schtasks.exe
2012-11-11 05:50:13.679, Window 'C:\Windows\system32\schtasks.exe' activated.
2012-11-11 05:50:13.688, --winwait schtasks.exe maxwait: 6
2012-11-11 05:50:13.695, test exename: schtasks.exe
2012-11-11 05:50:13.905, Window: schtasks.exe
2012-11-11 05:50:14.412, Windowhandle: 0x002403DC
2012-11-11 05:50:14.417, --winwait schtasks.exe waited: 0
2012-11-11 05:50:14.423, Send: {ENTER}
2012-11-11 05:50:14.721, Send:
2012-11-11 05:50:17.183, Debug logging enabled
2012-11-11 05:50:17.188, Executable Filepath specified: schtasks
2012-11-11 05:50:17.194, Executable Parameters specified: /create /xml "X:\Task.xml" /ru "COMPUTER NAME\USER NAME" /tn "Imported Task"
2012-11-11 05:50:17.231, Filemode, reading from file: X:\Wait.sro
2012-11-11 05:50:17.237, exename: schtasks
2012-11-11 05:50:17.241, Window: schtasks.exe
2012-11-11 05:50:17.313, Windowhandle: 0
2012-11-11 05:50:17.319, Running executable: schtasks /create /xml "X:\Task.xml" /ru "COMPUTER NAME\USER NAME" /tn "Imported Task"
2012-11-11 05:50:17.474, Running executable PID: 3036
2012-11-11 05:50:17.503, Title for PID: 3036 hWND: 0x000C0440 / C:\Windows\system32\schtasks.exe
2012-11-11 05:50:17.510, Window 'C:\Windows\system32\schtasks.exe' activated.
2012-11-11 05:50:17.519, --winwait schtasks.exe maxwait: 6
2012-11-11 05:50:17.526, test exename: schtasks.exe
2012-11-11 05:50:17.877, Window: schtasks.exe
2012-11-11 05:50:18.383, Windowhandle: 0x000C0440
2012-11-11 05:50:18.389, --winwait schtasks.exe waited: 0
2012-11-11 05:50:18.395, Send: {ENTER}
2012-11-11 05:50:18.518, Send:
2012-11-11 05:50:20.586, Debug logging enabled
2012-11-11 05:50:20.592, Executable Filepath specified: schtasks
2012-11-11 05:50:20.598, Executable Parameters specified: /create /xml "X:\Task.xml" /ru "COMPUTER NAME\USER NAME" /tn "Imported Task"
2012-11-11 05:50:20.623, Filemode, reading from file: X:\Wait.sro
2012-11-11 05:50:20.631, exename: schtasks
2012-11-11 05:50:20.637, Window: schtasks.exe
2012-11-11 05:50:20.702, Windowhandle: 0
2012-11-11 05:50:20.707, Running executable: schtasks /create /xml "X:\Task.xml" /ru "COMPUTER NAME\USER NAME" /tn "Imported Task"
2012-11-11 05:50:20.892, Running executable PID: 1316
2012-11-11 05:50:21.011, Title for PID: 1316 hWND: 0x000D0440 / C:\Windows\system32\schtasks.exe
2012-11-11 05:50:21.019, Window 'C:\Windows\system32\schtasks.exe' activated.
2012-11-11 05:50:21.027, --winwait schtasks.exe maxwait: 6
2012-11-11 05:50:21.036, test exename: schtasks.exe
2012-11-11 05:50:21.292, Window: schtasks.exe
2012-11-11 05:50:21.812, Windowhandle: 0x000D0440
2012-11-11 05:50:21.818, --winwait schtasks.exe waited: 0
2012-11-11 05:50:21.825, Send: {ENTER}
2012-11-11 05:50:22.141, Send:
2012-11-11 05:50:23.673, Debug logging enabled
2012-11-11 05:50:23.679, Executable Filepath specified: schtasks
2012-11-11 05:50:23.685, Executable Parameters specified: /create /xml "X:\Task.xml" /ru "COMPUTER NAME\USER NAME" /tn "Imported Task"
2012-11-11 05:50:23.691, Filemode, reading from file: X:\Wait.sro
2012-11-11 05:50:23.704, exename: schtasks
2012-11-11 05:50:23.710, Window: schtasks.exe
2012-11-11 05:50:23.727, Windowhandle: 0
2012-11-11 05:50:23.744, Running executable: schtasks /create /xml "X:\Task.xml" /ru "COMPUTER NAME\USER NAME" /tn "Imported Task"
2012-11-11 05:50:23.891, Running executable PID: 2484
2012-11-11 05:50:24.309, Window '' not found.
--- End quote ---

Ath:
Can you attach your Strokesfile please?

Edit: Seeing that you (seem to have) added --winwait schtasks.exe 6 to wait a maximum of 6 seconds for the executable to be loaded, that is probably the solution you need. Running the executable without permitting it some time to get running is apparently a bit too quick.
That's not an error, a feature or a bug, but just how things go (in Windows), IMHO.

Day Agent:
The Strokesfile is very basic:

--winwait schtasks.exe 6
{ENTER}

I tried:

--winwait schtasks.exe
{ENTER}

but the result(ing logfile) is the same.

The 'Window '' not found' error is thrown immediately, whether waiting for 6 seconds or not. Wouldn't the logfile show a time-out error if that were the problem?

This is what happens:


* I open an elevated command prompt and enter: WinSendKeys -x schtasks -xp "/create /xml ""X:\task.xml"" /ru ""COMP. NAME\USER NAME"" /tn ""Imported Task""" -f "X:\Wait.sro" schtasks.exe
* When I hit [Enter], almost immediately (-1 second) a new command prompt window opens, which states "Please enter the run as password for COMPUTER NAME\USER NAME:"
* - When things work as intended, WinSendKeys sends am [Enter] and the window closes.
* - When they don't, almost at the same moment the new command prompt opens (so fast, it's hard to tell which is first) a window pops-up with the 'Window '' not found' error.
I have noticed that if I repeatedly start WinSendKeys (with my line), it will error from the first try and keep on erroring until it works. Then it will work until it errors. It will usually error only once and then work again a number of times in a row, etc.

Navigation

[0] Message Index

[*] Previous page

Go to full version