Jump to content

ShellExecute, Run etc., under RDP launches in @SW_HIDE state only


Semmy
 Share

Recommended Posts

Hallo!

I'm using my server through RDP. And I've noticed that when I run my compiled AutoIt script through RDP it works correctly and I have what I want: The state of window that I launch is correct, but if I use task scheduler and have a task in it to run my script at a certain time, program which launched by the script runs in hidden mode (when scheduler runs a task no user is logged in). In order to exclude different controversial situations I tried with a trivial script. It consists only of 1 string:

Run("C:\Windows\System32\notepad.exe", "C:\Windows\System32", @SW_MINIMIZE)

So when I log in by RDP, I see that there's no window of notepad, but in Windows Task Manager there is a notepad.exe process.

Also I tried to use "search" but found nothing :x

Sorry if my english is bad. Respectfully yours, Semmy.

Link to comment
Share on other sites

  • Developers

Just some out-loud thinking:

The scheduler runs the tasks in the background and will not interact unless you tell it to by checking the "interact with desktop" checkbox on the logon tab.

When you have check this, I assume it will only interact with the console session, not all RDP sessions, so you will have to connect to that console session with RDP.

So, how are you connecting to the Win2k? server?

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Finaly I read FAQ :P:shifty: and found this

Why doesn't my script work on a locked workstation?

On locked station any window will never be active (active is only dialog with text "Press Ctrl+Alt+Del") In Windows locked state applications runs hidden (behind that visible dialog) and haven't focus and active status. So generally don't use Send() MouseClick() WinActivate() WinWaitActive() WinActive() etc. Instead use ControlSend() ControlSetText() ControlClick() WinWait() WinExists() WinMenuSelectItem() etc. This way you may have your script resistive against another active windows. It's possible to run such script from scheduler on locked Windows station.

May be it is the answer. I just found it strange that script which was launched before user logged out runs programs normally, not in hidden mode.

Anyway Thank's to AutoIt & Co! :x

Link to comment
Share on other sites

Jos,

Thank u for reply!

I'm connecting to remote server which is powered by Windows 2008 server. Through the standart RemoteDesktop tool. There is only 1 user: Administrator.

When I run script through rdp it works correctly. When my script (which was launched when I was logged in) reruns program when I'm not logged, it does it perfectly. But if script launched by task scheduler everything is in hidden mode. I don't know if I expressed my problem quiet understandable, I hope so :x

Semmy.

Link to comment
Share on other sites

If you let scheduler run the script, and there is no user logged in, then the application is run in the background. There is no other option because there is no user that created the desktop process. It is also a security restriction by Windows. It's the same reason why services (run in background) cannot interact with the desktop by default.

Link to comment
Share on other sites

  • Developers

Jos,

Thank u for reply!

I'm connecting to remote server which is powered by Windows 2008 server. Through the standart RemoteDesktop tool. There is only 1 user: Administrator.

When I run script through rdp it works correctly. When my script (which was launched when I was logged in) reruns program when I'm not logged, it does it perfectly. But if script launched by task scheduler everything is in hidden mode. I don't know if I expressed my problem quiet understandable, I hope so :x

Semmy.

You mainly just reiterated your initial post without mentioning most items in my post. :shifty:

So:

1.Have you set the Scheduled task to interact with the desktop?

2.Are you RDPing into the console session (0) or just start a new session when checking for the Script?

Jos :P

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

There is no other option because there is no user that created the desktop process.

Yes, I understand, thnx. But when user logged out, and script is already running and starts program is there any user that create desktop process?

You mainly just reiterated your initial post without mentioning most items in my post. :shifty:

So:

1.Have you set the Scheduled task to interact with the desktop?

2.Are you RDPing into the console session (0) or just start a new session when checking for the Script?

Jos :P

Sorry for that..

1. I found checkbox u were telling about. In Servises/Task Scheduler properties, but this checkbox is greyed out.... :x Is there any way to fix it?

2.

In Windows Server 2008, the /console switch has been deprecated.

And it is no longer needed. proof link. Also I don't use /admin option. Edited by Semmy
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...