Sign in to follow this  
Followers 0
daashag

Does anyone know?

13 posts in this topic

Is it possible to run a script as a schedule task?

I apologize for re-posting on the same topic, but I have asked this question before but have yet to get a clear answer. I have searched the forums and have found threads where this is being attempted but none with a solution. I have tried to run it as service according to Q4 of FAQ, ControlClick(), ControlSend(), and regualar window controls. I tried using RDP to login and then run the script. Has anyone been able to accomplish this? Would appreciate any feedback on this.

Thanks

Share this post


Link to post
Share on other sites



Is it possible to run a script as a schedule task?

I apologize for re-posting on the same topic, but I have asked this question before but have yet to get a clear answer. I have searched the forums and have found threads where this is being attempted but none with a solution. I have tried to run it as service according to Q4 of FAQ, ControlClick(), ControlSend(), and regualar window controls. I tried using RDP to login and then run the script. Has anyone been able to accomplish this? Would appreciate any feedback on this.

Thanks

Hi,

will there be a loggedOn User when the script starts?

So long,

Mega


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites

The way I am trying right now is with no logged in user.

Thanks

Share this post


Link to post
Share on other sites

Hi,

I guess then i will be hardly possible to use Window operating funcs.

So long,

Mega


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites

As long as your program is not GUI based and doesnt need input, then you can add a scheduled task to execute when the machine is at a login prompt or logged in as a user.

I use AT.exe, which is an XP dos app that creates scheduled tasks. The task runs as System by default, but has the option of being able to interact with the logged in user if /interactive is used to create the task.

Here is an example of how a task is setup with AT:

at.exe 00:00 /EVERY:m,t,w,th,f,s,su "C:\Program Files\Spybot - Search & Destroy\SpybotSD.exe" /taskbarhide /autoupdate /autoclose'

This will create a task that runs at night at 12 and executes every day of the week.

If your application has GUI elements to it, I don't know how those elements could be interacted with with not current user.

Hope this helps.

Share this post


Link to post
Share on other sites

Is there a way around this other than leaving someone logged into the box at all times?

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Is there a way around this other than leaving someone logged into the box at all times?

If the task is scheduled with AT.exe, the System account is used, and does not need a logged in user to run. The task will run with the privilages and environment of "System". Since System does not get its own desktop environment, things such as GUIs don't do too much.

Is your application GUI based, or headless?

Edited by austinsr

Share this post


Link to post
Share on other sites

If the task is scheduled with AT.exe, the System account is used, and does not need a logged in user to run. The task will run with the privilages and environment of "System". Since System does not get its own desktop environment, things such as GUIs don't do too much.

Is your application GUI based, or headless?

Thanks for your reply,

My application is GUI Based. It will work if I am RDP when the scheduled task runs even If I have the window minimized. Is it possible to first RDP in then run the autoit script. Basically have a script that RDP in and then executes another script. I don't need to worry about logging off as I reboot the server everynight anyway.

Thanks

Share this post


Link to post
Share on other sites

I think you can setup RDP to launch an application after the connection is made.

Share this post


Link to post
Share on other sites

The following code will open a RDP then run notepad on the the on the computer that is executing the script. How do I make it so it will run notepad on the RDP computer "Server1"

Run('mstsc.exe "' & @MyDocumentsDir & '\Connect\Server1.rdp"') 

WinWait("Server1 - Server1 - Remote Desktop","")
If Not WinActive("Server1 - Server1 - Remote Desktop","") Then WinActivate("Server1 - Server1 - Remote Desktop","")
WinWaitActive("Server1 - Server1 - Remote Desktop","")
Run("Notepad.exe", "", @SW_MAXIMIZE)

Thanks

Share this post


Link to post
Share on other sites

Your Server1.rdp needs "alternate shell:s:notepade.exe" entry.

Share this post


Link to post
Share on other sites

Appreciate your help Joon, you got me pointed into the right direction. I am able to make this work with two scripts. The first script logins in using the following code.

Run('mstsc.exe "d:\\test\Server1.rdp"')

On the Server1.rdp I have it execute the second script upon logging in. You can set that in your options of your .rdp file.

Share this post


Link to post
Share on other sites

Nice idea!

But I can't seem to make that "alternate shell" command work.

I generated my .rdp file using mstsc.exe, but although it connects fine, the command I specified is not run when I connect...

Any idea why that would be ?

I tried to copy/paste the command line from the .rdp file into the Start > Run... of the PC to which I connect using RDP, and the command launches fine. I also tried

alternate shell:s:C:\WINDOWS\system32\notepad.exe

without success...

- Guillaume Boudreau

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  
Followers 0