0

I have made a simple application in C# and WHITE, which click on a button to clear the logs. I use to connect to my test machine using Remote Desktop Connection and execute that application. It works fine when my session is connected but whenever i disconnect my session, it stops working.

Is there any way to execute that application when windows session is disconnected?

matino
  • 17,199
  • 8
  • 49
  • 58
user288645
  • 331
  • 1
  • 4
  • 15
  • I assume your program wouldn't stop working, just your UI automation...? – Merlyn Morgan-Graham Nov 16 '11 at 08:55
  • WHITE is a wrapper on Microsoft UI Automation – user288645 Nov 16 '11 at 09:35
  • I knew that, but I feel it isn't presented clearly enough in your question. UI automation won't run if you don't have a UI session. So, no there is no way. But how do you clear your logs? What logs? Maybe there is another way to go about this that doesn't require you to use UI automation? – Merlyn Morgan-Graham Nov 16 '11 at 10:49
  • A hack might be to use other remoting applications so you can keep your desktop session unlocked. See this post: http://www.autohotkey.com/forum/topic26698.html – Merlyn Morgan-Graham Nov 16 '11 at 10:52
  • Actually, I am using Debugview for gathering the log for finding the bug. DebugView is used in StressTest and StresTest generates tremendous log. In 1 min DebugView consume 13 MB of RAM and StressTest has to be executed for at least 5 hrs so therefore i have created a small application which clear it(click on the button on Debug view) after 1 minute and this process continues. – user288645 Nov 17 '11 at 06:34

4 Answers4

2

You could write a Windows Service.

Darin Dimitrov
  • 1,023,142
  • 271
  • 3,287
  • 2,928
1

You could also use the task scheduler. You may not need the C# wrapper, you can add yourself the required entry within the scheduler.

Guillaume
  • 12,824
  • 3
  • 40
  • 48
0

Taken from https://www.ranorex.com/help/latest/ranorex-remote/remote-faq#c13444

Create a batch file on your remote machine and insert the code below:

for /f "skip=1 tokens=3 usebackq" %%s in (
  `query user %username%`
) do (
 %windir%\System32\tscon.exe %%s /dest:console
)

Save this batch file on the desktop of your remote machine and name it: 'KeepSessionOpen.bat'. If you need to disconnect the RDP session, you can now simply run this batch file using administrator privileges and your remote machine will remain unlocked.

Jason
  • 41
  • 4
  • You will also have to disable the screen saver as when screen saver is presented the logged in account will be locked. – Martin Jan 15 '18 at 07:53
0

It works fine when my session is connected but whenever i disconnect my session, it stops working.

This is by design. When you disconnect your session, it is locked. When your session is locked, UI automation won't work.

You could hack around this by never locking the session, possibly via different remote desktop tools (VNC/PcAnywhere). But this is definitely a hack.

Instead I suggest a different approach. I recommend avoiding UI automation whenever possible. I have always found UI automation to be flaky and unreliable.

In the comments on your question you said your app is simply UI automation to click a button to clear a log. The logs are generated by the DebugView application.

I suggest you log to a file instead. This feature is mentioned on the web site for DebugView:

http://technet.microsoft.com/en-us/sysinternals/bb896647

You could also look into using remote monitoring.

If size is an issue, you can also look into the "Log file wrapping" and "log-file rollover" features.

Merlyn Morgan-Graham
  • 58,163
  • 16
  • 128
  • 183
  • I am loging it to a file but only i care is the memory consumption of DebugView. When logs are heavily generated , debugview consumes lot of memory(upto GB's). The only option i found is to clear the display by pressing Clear(Ctrl+X) button after 1 min. – user288645 Nov 17 '11 at 08:26