On this server I am trying to send keys to a Chrome window (which another VB application opens first) to download a file. This is the code, and it works when logged into the machine:
Code: Select all
SetTitleMatchMode, 2
WinWait, Ads Manager - Reporting, ,120
if ErrorLevel
{
MsgBox, WinWait timed out.
return
}
else
{
Sleep 10000
WinActivate, Ads Manager - Reporting
;WinMaximize
Sleep 2000
SendInput, {tab 20}
SendInput, {enter}
Sleep 1000
SendInput, {enter}
}
It runs fine on my local Windows 10 PC, as well it also runs fine on the server when I am logged in and looking at the Windows GUI. It does not work when run from Task Scheduler when I am disconnected.
If I disconnect from the server using this in a BAT file, it seems to keep the console open. But not when I disconnect normally (always using this BAT file to disconnect is not a viable option).
Code: Select all
for /f "skip=1 tokens=3" %%s in ('query user %USERNAME%') do (tscon.exe %%s /dest:console)
Is there some way to force the console/GUI back on in some way? I have completely control of the server to do as I wish.