Process memory increasing after switching user - wpf

I've developed an app that runs on windows. It uses a 5 mintes timer to initiate a connection to an Web service and checks for any updates in a DataTable.
If there are any changes - it pops a WPF window on the client and shows a message.
The program runs in our domain using a Logon Script, and runs with the users account.
Lately we've noticed a problem, and found out that the process of the app was using over 2GB of ram on them, and increasing...
After looking it up, we figured out the problem:
The app runs on windows xp and windows 7 pcs. In windows 7, if a user uses the "Switch User" option, the process of the first user keeps on running, and the 5 minutes timer is still running. The memory leak strarts when there's a change, and a message should be displayed.
When we stopped the timer, and then used "Switch User" - There was no problem and the process stayed on a normal memory usage.
What can we do? Any suggestions?
Thanks!!

I use the following method to enumerate current users.
ManagementObjectSearcher searcher = new ManagementObjectSearcher("SELECT UserName FROM Win32_ComputerSystem");
ManagementObjectCollection collection = searcher.Get();
foreach (var user in collection.Cast<ManagementBaseObject>())
{
Console.WriteLine(user["UserName"]);
}
It might work in your app if you use this and compare with:
System.Security.Principal.WindowsIdentity.GetCurrent().Name
If not a match - pause the instance.
If you have a memory leak, it would suggest a missing dispose in your method too. I'd be surprised if you ended up with enough instances to merit 2GB memory allocation.
P.S - requires you add reference to System.Management

Related

React Kiosk App keeps crashing on Chrome - Chrome not Responding

We have a Kiosk app which runs on Chrome Kiosk mode and is written in React JS. But for some of our Kiosk machines (All of our machines are Windows machines), it seems to be crashing regularly (Approx. %4 of the devices) without any user input or fixed time between crashes.
I reviewed the code several times but never found any background tasks running, or any reason for the Chrome to crash at all.
Because the crashes are irregular, I cannot connect to a problematic device and wait for it to crash for hours to debug the process. And because the app is automatically started via a VB script when Windows is started, the clients often "solve" the crashes by restarting the Kiosk machine, which is time consuming and leads to tons of complaints.
So my questions are;
Can I somehow force Chrome to restart, or lets say Go to first page in history if it crashes?
Can I catch errors globally without using ErrorBoundries in JavaScript (It is already implemented and is used for other things)
I tried using --remote-debugging-port=9222 to use Developer Tools, but I need to be connected to the machine and go to localhost:9222 port manually to use this and cannot afford to be connected to the device all the time. So is there a way to connect and use Developer Tools on 9222 port remotely?
I tried saving console logs to a file (using Chrome Command Line Arguments) but never saw any "Errors" on the list, so is there any arguments to help me save crash logs to a file to inspect them after the crash?
Thanks for all your help.

How to relaunch current program in macOS with execl("/usr/bin/open"...)?

I can successfully launch an app with
execl("/usr/bin/open", "open", "/Applications/Foo.app", 0);
But this doesn't work when I'm calling it inside Foo.app
I want my app to relaunch itself when it crashes and autoupdates.
Thanks!
open won't start a second instance of your app if one is already running, it will simply make it the active app.
You can start a second instance of your app by executing the app bundle's executable:
excel("/Applications/Foo.app/Contents/MacOS/Foo", ...
While not the recommended way to launching a Cocoa app, I've been assured by Apple engineers that this will work. But be warned, you now have two instances of your app running, sharing the same NSUserDefaults, and other resources, so expect some strange behavior (or immediately terminate the first app through exit()).
Having said that, this probably isn't want you want to do.
First, you can't "detect a crash and take some action" as—by definition—your app has crashed. There are packages out there that will detect a crash and log information about it; look to a solution like that to restart your app.
As for updates, again I'd steer you towards a third-party solution like Sparkle. It handles quitting your old app, replacing it, and then launching the new one in a sane manner.
Finally, you can register your app as a "user agent" with launchd so that it gets automatically restarted if it quits.

Remote Desktop Application - Start multiple sessions on my client PC

I have a windows 2016 server running RDS. It is configured to run a single application when a user accesses it from a .rdp shortcut. The user just sees the application as though it is running on their local machine, not a whole remote desktop.
If from a client PC, if I launch the application and log in then I can see a new connection in the RD Gateway manager.
However if I launch the application from the same client PC multiple times I am only asked to login the first time, and whilst I see many instances of the application I only see one connection in the RD gateway manager.
I would like a new connection each time I launch the application, so that I can simulate multiple users running the app concurrently in their own sessions.
I have tried adding "prompt for credentials on client:i:1" to the .rdp shortcut and this has no effect.
Thanks you your help.
I don't think it's possible. Let me try to explain:
Whenever you launch the RDP file, you connect to a session on the RDSH. Now, if you want separate connections, that means that there should be multiple sessions (probably for the same user since the credentials don't change) which is not allowed by the RDSH by default.
Assuming you get passed multiple sessions for same user, MSTSC actually recognizes that for the given RDP file, there is already an open connection, so it will try to reuse that.
Last but not least, there is the problem of licensing - you are "working around" the system: both per-device and per-user licensing would report 1, therefore it would probably be a violation of ToS.
It would be much more useful if you could tell us what you are trying to achieve and then maybe we can help you more.
P.S.: This question has nothing to do with programming, so it probably belongs to https://superuser.com
Hi I figured out a solution to this, so I will share in case it is useful for anyone else.
Modify the hosts file to include different names for the target machine ip address:
eg:
51.xxx.159.233 test1.xxx.uk-user1
51.xxx.159.233 test1.xxx.uk-user2
51.xxx.159.233 test1.xxx.uk-user3
51.xxx.159.233 test1.xxx.uk-user4
Then in each rdp launch shortcut, reference a different alias.
eg:
Shortcut1:
full address:s:test1.xxx.uk-user4
Shortcut2:
full address:s:test1.xxx.uk-user3
Then when the RDP is launched it will ask you to log in even if you already have an active connection and server will have a new user logged into it.
Hope this helps somone in the future.

Captured DevTest Labs is not working

I have pressed the capture button on a VM in dev test labs. Now it looks like I have a generalized VM that looks useless to me. For example, I can not start the VM anymore. It just displays the following error message.
Failed to start virtual machine 'vmname'. Error: Operation 'start' is not allowed on VM 'vmname' since the VM is generalized.
I need to access this VM what can I do ?
** Should I have run sysprep before I hit the capture???
As I can not start another VM it give this error. Provisioning failed.
OS Provisioning for VM 'IntegrationTest' did not finish in the
allotted time. However, the VM guest agent was detected running. This
suggests the guest OS has not been properly prepared to be used as a
VM image (with CreateOption=FromImage). To resolve this issue, either
use the VHD as is with CreateOption=Attach or prepare it properly for
use as an image: * Instructions for Windows:
Don't use this button without SYSPREP.
Use regular backup.
IMHO the capture process is not as easy as AWS EC2... This error* caused us a day.
*It was my fault to hit the button where I thought it would just work. I should have tested it.

Execution of QTP scripts on remote machines

I am posting this question regarding the execution of QTP scripts on remote machine. When i log in to my remote machine via "mstsc", and execute the script without closing the remote desktop connection, it works fine. But once i close/minimize the remote desktop window, it starts throwing error ( like Object not visible" error.
One of the places where it generally throws error is while clicking on the file menu in IE, as shown below :-
Browser(" page name -").WinToolbar("ToolbarWindow32").Press "&File"
Are there any workarounds to resolve the same??
Most of the QTP scripts take lot of time to execute, and if the prerequisite is to keep the screen active without even locking, isnt it one of the key disadvantages?
Thanks in advance!!!
Steve
QTP replays some steps by manipulating the mouse and keyboard devices. When an RDP session is minimized windows knows that there is nobody at the controls and therefore doesn't respond to the mouse and keyboard events which causes QTP to fail.
A workaround to this is to connect to the machine via another application rather than mstsc (for example VNC) which doesn't communicate to windows that it has been minimized. Either that or leave the RDP window open.
If you want to run QuickTest in a minimized RDP session, and you are using an RDP >= 6.0 client, you can enable it by setting a registry value on the local computer:
Navigate to one of the following registry paths on the local computer:
Current User: HKEY_CURRENT_USER\Software\Microsoft\Terminal Server Client
or
All Users: HKEY_LOCAL_MACHINE\Software\Microsoft\Terminal Server Client
Create a DWORD value named RemoteDesktop_SuppressWhenMinimized and set it to 2.
Note that this does not work when the computer is locked or logged off.
one more simple way
just maximize RDP session , then scripts will run don't minimize
you remove the lock of the machine.

Resources