Sign in to follow this  
Followers 0
Intellitree

Scheduled scripts on logged out server.

4 posts in this topic

#1 ·  Posted (edited)

:o After Throwing myself into the AutoIt world head first I've completed my first script (only took 8 hours). Now comes the problem. this script is to run on a windows 2003 server that is not generally left logged in. I coded the script using a remote desktop and tested it. It works perfectly. Now comes the hard part. How can I using 'Scheduled Tasks' or the 2003 equivelent execute this script.

Included is the script itself (made websafe, most variables now empty)

[ code ] ;

#include <Date.au3> ; This is needed to manipulate the dates in the script

Dim $Y, $M, $D, $xlsfile, $execpath, $mailprog, $cmd, $sqlname, $sqlpass, $smtpserver, $fromemail, $emailsendto, $toemailB, $subject, $message

$execpath = "c:\msi\msi.exe" ; The report generation program

$mailprog = "c:\msi\sendEmail.exe" ; A Tool for Sending SMTP Email from a Console. http://caspian.dotconf.net/menu/Software/SendEmail/

$xlsfile = "c:\msi\1542.xls" ;File name and path to save report to, this file is later emailed.

$cmd = "c:\windows\system32\cmd.exe" ; Command interpreter

$sqlname = "" ; Username used to login to mysql.

$sqlpass = "" ; Password for the given user.

$smtpserver = "" ; IP address of smtp server on network. Currently IP of SCN01.

$fromemail = "" ; email address the email will be from, this email does not need to be valid.

$emailsendto = "" ; Email List of comma seperated addresses to send to. One person is responsible for forwarding to Maritz.

$subject = "" ; Subject line of Email. Can be anything.

$message = "" ; Message of Email, this also can be anything.

Run($execpath)

AutoItSetOption("SendKeyDelay", 30)

WinWaitActive("msi.rpt")

Send("!O")

WinWaitActive("Export")

ControlClick("Export", "Format", 1)

WinWaitActive("Choose Export File")

Send("!n")

Send("" & $xlsfile)

Send("!S")

Sleep(500)

If WinExists("File already exists") Then

Send("!Y")

EndIf

WinWaitActive("msi.rpt")

ControlClick("msi.rpt", "Print", 451)

WinWaitActive("Logon Parameters")

ControlSend("Logon Parameters", "", 1003, "{DELETE 2}" & $sqlname)

ControlSend("Logon Parameters", "", 1004, "" & $sqlpass)

Sleep(500)

ControlClick("Logon Parameters", "", 1)

WinWaitActive("Enter Parameter Values", "Enter Beginning")

WinMove("Enter Parameter Values", "Enter Beginning", 0, 0)

$sJulDate = _DateToDayValue(@YEAR, @MON, @MDAY)

$sJulDate = _DayValueToDate($sJulDate - 8, $Y, $M, $D)

Send("" & $M)

Sleep(500)

Send("/" & $D)

Sleep(500)

Send("/" & $Y)

Sleep(500)

WinWaitActive("Enter Parameter Values", "Enter Beginning")

MouseClick("left", 26, 60)

Sleep(500)

WinWaitActive("Enter Parameter Values", "Enter Ending")

$sJulDate = _DateToDayValue(@YEAR, @MON, @MDAY)

$sJulDate = _DayValueToDate($sJulDate - 1, $Y, $M, $D)

MouseClick("left", 140, 200)

Send("" & $M)

Sleep(500)

Send("/" & $D)

Sleep(500)

Send("/" & $Y)

Sleep(500)

MouseClick("left", 26, 70)

WinWaitActive("Enter Parameter Values", "Enter Prop. ID")

ControlSend("Enter Parameter Values", "Enter Prop. ID", 1001, "001542")

ControlClick("Enter Parameter Values", "", 1)

Sleep(10000)

WinWaitActive("msi.rpt")

Send("!D")

ControlClick("msi.rpt", "Done", 2)

Sleep(10000)

Run($cmd)

WinWaitActive("C:\WINDOWS\system32\cmd.exe")

Send($mailprog & " -s " & $smtpserver & " -f " & $fromemail & " -t " & $emailsendto & " " - u " & $subject & " - m " & $message & " - a " & $xlsfile & " {ENTER}")

Sleep(10000)

Send("exit {ENTER}")

[ /code ] ;

Edited by Intellitree

Share this post


Link to post
Share on other sites



please add the code tags so its easier to read

[ code ] ; no spaces

; paste your code

[ /code ] ; no spaces

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

this script is to run on a windows 2003 server that is not generally left logged in.

Not Logged In == NO CONSOLE

WinWaitActive("msi.rpt")

NO CONSOLE == No Window can ever become active.

ERGO Script will not work as expected w/o a logged on user.

Possible workarounds - refer to other forum threads that have repeatedly addressed this issue.


Reading the help file before you post... Not only will it make you look smarter, it will make you smarter.

Share this post


Link to post
Share on other sites

Not Logged In == NO CONSOLE

NO CONSOLE == No Window can ever become active.

ERGO Script will not work as expected w/o a logged on user.

Possible workarounds - refer to other forum threads that have repeatedly addressed this issue.

After a quick look round I found many of those threads, they all said it was impossible. But I also saw references to logging in, running script, logging out. unfortunatly no one said how. It it possible to script a login to the pc. I know how to modify auto login after boot up but that is not what is needed.

Any help greatly appreciated.

If machine was locked could it detect the login window and send crtl_alt_del plus pass?

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