Jump to content

Script Running On Remote Desktop


Recommended Posts

The below script runs a headless box that is controlled by remote desktop. The problem is that it will only start and complete when i'm connected and viewing the remote desktop. I don't know if it a problem with the WinActivate lines or what, but when it gets to those lines and I'm not connected, the script just pauses. Soon as as I reconnect and tap the working window with my mouse, the script starts back up and finishes w/o errors. Anyone know whats going on? I can't watch all the time.

Oh yea. I don't actually logoff the server, I just disconnect. The account is still active and running.

;-----------------------------------------------------------------------------
; backup bandwidth monitor pro logs
;-----------------------------------------------------------------------------
DirCopy("\Program Files\Bandwidth Monitor Pro\Stats", "\usi_utils\bandwidth_bypass\backup\bmp_logs", 1)

;-----------------------------------------------------------------------------
; close bandwidth monitor pro
;-----------------------------------------------------------------------------
RunWait("\usi_utils\bandwidth_bypass\batch\kill_BMP.bat", "")

;-----------------------------------------------------------------------------
; find the current mac address via batch
;-----------------------------------------------------------------------------
RunWait("\usi_utils\bandwidth_bypass\batch\current_mac.bat", "")


;-----------------------------------------------------------------------------
; find and copy results from ipconfig_results.txt routine
;-----------------------------------------------------------------------------
Run("notepad.exe")
WinWait("Untitled - Notepad")
WinActivate("Untitled - Notepad", "")
Send("^o")
WinActivate("Open", "")
Send("\usi_utils\bandwidth_bypass\current\ipconfig_results.txt{ENTER}")
WinActivate("ipconfig_results.txt - Notepad", "")
Send("^f")
WinActivate("Find", "")
Send("00-01-05{ENTER}")
WinActivate("Find", "")
Send("{TAB 4}{ENTER}{LEFT 5}")
Send("{BS}{:}{RIGHT 2}{DEL}{:}{RIGHT 2}{DEL}{:}{RIGHT 2}{DEL}{:}{RIGHT 2}{DEL}{:}{RIGHT 2}")
Send("{SHIFTDOWN}{LEFT 17}{SHIFTUP}")
Send("^c!fx")
WinWait("Notepad")
Send("!n")

;-----------------------------------------------------------------------------
; paste current mac address into change_mac.bat batch file
;-----------------------------------------------------------------------------
Run("notepad.exe")
WinWait("Untitled - Notepad")
WinActivate("Untitled - Notepad", "")
Send("^o")
WinActivate("Open", "")
Send("\usi_utils\bandwidth_bypass\batch\change_mac.bat{ENTER}")
WinWait("change_mac.bat - Notepad")
Send("^f")
Send("set var3={ENTER}{TAB 4}{ENTER}")
Send("{LEFT}{RIGHT}{SHIFTDOWN}{RIGHT 17}{SHIFTUP}")
Send("^v!fx")
WinWait("Notepad")
Send("!y")

;-----------------------------------------------------------------------------
; execute change_mac.bat and finish
;-----------------------------------------------------------------------------
RunWait("\usi_utils\bandwidth_bypass\batch\change_mac.bat", "")

;-----------------------------------------------------------------------------
; wait 10 & restart BMP
;-----------------------------------------------------------------------------
Sleep(10000)
Run("\Program Files\Bandwidth Monitor Pro\Bandwidth Monitor Pro.exe", "")

;-----------------------------------------------------------------------------
; display textbox informing of mac address change
;-----------------------------------------------------------------------------
MsgBox(64, "Bandwidth Bypass Utility", "Mac address has been changed!")
Link to comment
Share on other sites

I think since your not logged into the remote PC, there isn't a session open for your program to work. How are you starting your script remotely?

Bandwidth monitor pro calls it up when X amt of bandwidth has been reached. It does call it up just fine, but like I said, it pauses.

Link to comment
Share on other sites

Hi,

I am having the same problems as well.

Basically when i am viewing the RDC (Remote Desktop Connection) window my scripts run perfectly without any problems, but when i am not viewing the RDC Window the scripts fail.

I get this error most on the 'winclose' function

Im not sure what it is but hopefully someone will know

Link to comment
Share on other sites

...I don't actually logoff the server, I just disconnect...

Doing that still locks the computer and most Win___ functions will not work in that mode.

@show,

Welcome to the forums. It is best to start a new topic - even if your problem is very close to another post. I has to do with the way that people keep track of "their threads".

WinClose should work - even on a locked computer. Do you have a WinWait___ before it? It would be easier to troubleshoot your code if we could see your code :-)

[size="1"][font="Arial"].[u].[/u][/font][/size]

Link to comment
Share on other sites

Auto IT does not execute the scripts remotely, the console needs to open for execution. If you check my post by my username : autoguy100 you can see my post.

This is something Autoit can include in next version.

Note: Remote execution is possible if you set Autologon, but i don't want to do that because of security issue.

Link to comment
Share on other sites

...the console needs to open for execution...

No, just a few Win___ related functions will not work when a computer is locked or no user is logged on. Many AutoIt functions will work just fine under those conditions.

[size="1"][font="Arial"].[u].[/u][/font][/size]

Link to comment
Share on other sites

No, just a few Win___ related functions will not work when a computer is locked or no user is logged on. Many AutoIt functions will work just fine under those conditions.

Win_ functions are important since since winactive or winactivate are important to get focus of window.

Link to comment
Share on other sites

Win_ functions are important since since winactive or winactivate are important to get focus of window.

...but so many things can be done without a window showing up... I have several scripts that run at night that just do InetGets, move files, gather data, write to files... and no windows are involved.

[size="1"][font="Arial"].[u].[/u][/font][/size]

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...