Jump to content

run autoit3 script remotely (no session)


Recommended Posts

Hi,

I created an aoutoit3 script which is running on windows server 2008.

this script runs ok when I logged on to his server. but when I disconnecting the server, the scrip is not running o.k.

Other scripts like ant, batch, perl etc. (not aoutoit3 script) run ok in the same way (dissconnected server).

this is the same behavior when I do the same on a regular PC (windows XP)

Is there a way to run the au3 script from not-logged-on server?

I will appreciate youe help!

Thanks,

Gadi.

Link to comment
Share on other sites

Lots of ways, but there are some restrictions, like no window ever becomes ACTIVE while running via a scheduled task or with the console locked. Send() should never be used. Use ControlSend() instead, etc.

The specific problem with your script can't be determined without some code to look at.

:mellow:

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Lots of ways, but there are some restrictions, like no window ever becomes ACTIVE while running via a scheduled task or with the console locked. Send() should never be used. Use ControlSend() instead, etc.

The specific problem with your script can't be determined without some code to look at.

:mellow:

Hey PsaltyDS why doesnt a window ever become ACTIVE while running scheduled? I always wondered this, is it some kind virus protection?

[Cheeky]Comment[/Cheeky]
Link to comment
Share on other sites

A process runs in a user context. Scheduled and remote tasks typically run in the SYSTEM context that has no "desktop" interaction... because the "desktop" is in the "current logged in user" context. Winows exist on a "desktop" ... if a context has no "desktop", then it has no windows to interact with.

Lar.

f_mrcleansmalm_77ce002.jpgAutoIt has helped make me wealthy

Link to comment
Share on other sites

Hi,

Thanks.

I use controlsend func.

here is the code

Opt("SendKeyDelay", 500)          ;50 milliseconds
; configuration files 
Dim $ssh=$CmdLine[2]
Dim $exec___=$CmdLine[3]
;cmd xexcutable
Dim $cmd_exec=$CmdLine[4]
Dim $jobid=$CmdLine[5]
dim $date_now= @MDAY & '_' & @MON & '_' & @YEAR & '_' & @HOUR & '_' & @MIN & '_' & @SEC
Dim $_path="c:\"
Dim $cmd_title="run_exec_running_cmd_line_" & $jobid & '_' & $date_now

If FileExists($_path & "\2.ttt") Then
    Dim $file_to_exec = "1.fff"
Else
    Dim $file_to_exec = "2.fff"
EndIf


While 1
$PID = ProcessExists('executable.exe')
If $PID Then
    ProcessClose($PID)
Else
    ExitLoop
EndIf
WEnd

Local $run_exec=Run($cmd_exec & " /C TITLE " & $cmd_title &"& C:\executable.exe " & $ssh & " " & $exec___ & "  " & $_path & "\" & $file_to_exec & "  | C:\tools\cots\cygwin_win32\usr\bin\tee.exe -a " & $_path & "\log 2>&1 ",$_path,@SW_HIDE)
sleep(2000)
ControlFocus ( $cmd_title, "", "" )
sleep(5000)

    ControlSend($cmd_title, "", "", "a")    
    ControlSend($cmd_title, "", "", "a")    
    ControlSend($cmd_title, "", "", "a")    
    ControlSend($cmd_title, "", "", "a")    
    ControlSend($cmd_title, "", "", "a")    
    ControlSend($cmd_title, "", "", "a")    
    ControlSend($cmd_title, "", "", "a")    

sleep(200)
ControlSend($cmd_title, "", "", "{ENTER}")
sleep(15000)
Edited by gadi
Link to comment
Share on other sites

the scheduled task can have "desktop" interaction by scheduling the task with

$time=@HOUR &':'& (@MIN+1)
Run('at '&$time& ' /interactive explorer')

which you will an explorer window in the next minute.

but becareful! this will run explorer in systems account!

sorry, but I'm not sure where should I add it?

to the current run command or open a new run command?

Link to comment
Share on other sites

oops...

I haven't read the topic quiet clearly....

PsaltyDS & LarryDalooza are right.

if the computer isn't logged-on,

no window ever becomes ACTIVE while running via a scheduled task or with the console locked

so stick to what they say...

The code i gave is to give your task have a window displayed(like GUICreate) when running the scheduled task(and only if the computer is logged on), but now I think you wouldn't want that if you are running things on the background.

Sorry.

Edited by MiserableLife
Link to comment
Share on other sites

oops...

I haven't read the topic quiet clearly....

PsaltyDS & LarryDalooza are right.

if the computer isn't logged-on,

so stick to what they say...

The code i gave is to give your task have a window displayed(like GUICreate) when running the scheduled task(and only if the computer is logged on), but now I think you wouldn't want that if you are running things on the background.

Sorry.

mmmmmmmmm ok

so is there any other solution to my problem?

:-(

Link to comment
Share on other sites

this needs "Task Scheduler" service to be turned on

add this to the beginning of the script

running this will run your script on the next minute using SYSTEMS account.

(not sure will this work in server 2008, but it works in XP)

change the code to suit your needs

abc()
;your script code
Msgbox(0,'',@UserName)

Func abc()
    $time = @HOUR& ':' & (@MIN+1)
    If @Compiled = 1 Then
        Run('at '& $time &' /interactive "'& @AutoItExe &'"','',@SW_HIDE)
    ElseIf @Compiled = 0 Then
        Run('at '& $time &' /interactive "'& @AutoItExe &'" "'& @ScriptFullPath &'"','',@SW_HIDE)
    EndIf
    Exit
EndFunc
Edited by MiserableLife
Link to comment
Share on other sites

this needs "Task Scheduler" service to be turned on

add this to the beginning of the script

running this will run your script on the next minute using SYSTEMS account.

(not sure will this work in server 2008, but it works in XP)

change the code to suit your needs

abc()
;your script code
Msgbox(0,'',@UserName)

Func abc()
    $time = @HOUR& ':' & (@MIN+1)
    If @Compiled = 1 Then
        Run('at '& $time &' /interactive "'& @AutoItExe &'"','',@SW_HIDE)
    ElseIf @Compiled = 0 Then
        Run('at '& $time &' /interactive "'& @AutoItExe &'" "'& @ScriptFullPath &'"','',@SW_HIDE)
    EndIf
    Exit
EndFunc

Hi,

I tried this code but it caused a lot of problem in my server (the system disabled using autoit3_x63 executable)

and I needed to reinstall autoit...

Can you please explain more your code (as I'm new with writing au3 scripts)

Thanks in advanced!

Link to comment
Share on other sites

:mellow: Did I screw your server up? I'm very sorry if I did.

that code I gave you is to run your script in Task Scheduler.

at is the cmd command line version to add tasks to Task Scheduler.(type at /? in cmd for details)

what is it that you are trying to do on the server?

Link to comment
Share on other sites

A process runs in a user context. Scheduled and remote tasks typically run in the SYSTEM context that has no "desktop" interaction... because the "desktop" is in the "current logged in user" context. Winows exist on a "desktop" ... if a context has no "desktop", then it has no windows to interact with.

Lar.

Yes, and Microsoft in their infinite wisdom decided that in 2008/Vista/7 not only services but also the locked desktop would run in an entirely separate environment from the logged-on user. This is allegedly more secure, but has the adverse effect that many things which could be done with services on XP/2003 have to be run in userspace on 2008.

Security enhancement? No. Reduction. In practice it mostly means you can never log the useraccount off, nor lock the desktop.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...