Detect application running in WinRT mode by PID - windows-8

Overview:
I need to detect if a given application is running in WinRT (aka "Metro") mode, by process/PID. Is there a good way of doing this?
Failed attempts and observations:
OpenProcess() and call Call GetPackageId() checking for != APPMODEL_ERROR_NO_PACKAGE: This seems to work for some processes while others such as Chrome when running in Metro mode fail the check.
Metro apps appear always be hosted (e.g. their parent) by svchost.exe
Any ideas? Please omit any "Don't do that" or "Why?" responses as they are not helpful to this particular question.

IsImmersiveProcess would return true if the process is running in Metro Mode. Note, that if the detecting app is running as a service then this call always returns false.

If the Metro app is running WWA Applet then get the command line arguement from the PID and see if it WWAHOST.exe. Not all metro apps are running as WWA applet for example, IE runs as a standalone exe in Metro mode.
This may sounds as a kludge but worked for me in detecting whether IE is in metro mode.
The IE process in metro mode is still iexplore.exe. It's root parent process in Metro mode is Wininit.exe where in non metro mode is explorer.exe.
So find the root parent PID for the IE's PID and then from the parent's PID get parent's process name then compare it against "Wininit.exe" or "Explorer.exe"

Related

QTP has stopped recording and spying

I've been working for few months with QTP (UFT One 15.0.2), and today it has stopped recording (when I do the actions no lines are written in the script and no objects are added to the objects repository) and recognizing objects with the spy feature.
I am using the WEB add-in, and as I've been working for months with Mozilla Firefox I have checked that the WebExtension.xpi is well added to the browser.
I've tried to open mozilla before and after UFT One, I've also restarted my computer, I've checked the size of the screen browser is 100% and that in the Record and Run Settings the option " Record and run on any open browser" is checked for Web.
This situation usually occurs because the company's IT department has changed the related policy, causing the UFT Firefox extension to fail to run normally.
You can check if the HP.UFT.Firefox.NativeMessagingHost running in Windows task manager after openning Firefox while the extension is enabled, and check if the Micro Focus UFT Agent content script loaded in Firefox debugger's Sources tab(note: you need to check the "Enable browser chrome and add-on debugging toolboxes" in Web Developer Tools' Setting firstly).
If one of these things does not exist, you should check the policy change with your IT: did they block the related thing running?
If they all exist, you can open a CPE case to UFT One support. They will help you to do the further investigation.
I have checked that I had the same problem with chrome browser, so not an Extension problem.
Finally I have decided to uninstall and reinstall UFT One, but while uninstalling an error appeared and UFT persisted on the system.
After two trys I have launched UFT One and it has started working again.
I am not sure how long it will work.

Specify screen resolution for coded UI tests

I am running coded UI tests using Selenium from a build in VSTS.
The test library is built on a test agent (hosted and private available) and copied to a VM running Windows 10. Then the test agent is deployed to the VM and the task 'Run Functional Tests' is executed. The tests to be executed are selected through an association in the test manager of VSTS.
I would like to run these UI tests (in Chrome) in different screen resolutions, but when the test agent is executed, the headless session always runs in the default resolution of 1024x768. I need to run tests up to a 4k resolution. If there is a current session with the same credentials in a higher resolution, this session is "hijacked" and the tests run in the desired resolution.
But I cannot guarantee an existing session when those builds are triggers by either a schedule or another event.
I already followed an MSDN article how to specify a default resolution in the registry, but that doesn't work on neither Win10 nor on Srv2012.
Is there a parameter/setting in a test/run setting file that specifies the resolution of this headless session?
To avoid confusion: I know how to set the windows size of the browser, but that is limited to the maximum screen resolution, so the Selenium-specific commands to resize the browser don't do the trick ;)
Any hint appreciated! Thanks!

How to run a command in cmd on startup in Windows XP

Sigh. For reasons, I am running a windows xp virtual box in ubuntu. In this instance of windows there is an express (node) server running. Everything works fine, except that occasionally windows crashes or the virtual box freezes (perhaps after being left idle for several days). I would like to restart the virtual box (and node server) programmatically when this happens. The actual restarting of the virtual box from linux seems attainable, but I can't figure out how to get windows to run "node .../server.js" on startup! I tried putting the command in C:\AUTOEXEC.bat, and it did not start when I restarted the computer. I know I'm asking for trouble with a 10 year old OS but it's what I have to work with. Any thoughts?
Try scheduling in as a task in the task scheduler.
Tasks get executed when their triggers are satisfied, and in this case you can use the 'at startup' trigger, as described here:
http://technet.microsoft.com/en-us/library/cc748841.aspx
At startup
This trigger causes the task to run when the computer starts up. The only settings for this trigger are the advanced settings described in the Advanced Settings section below.
Look out though, that information wasn't tailor-made for XP, but should do it for you.
I actually just got it working. I put a batch file in start/programs/startup that CD'd to the right directory and then ran node.

Metro console application in Windows 8

Is there a way to build metro application that runs in console?
There is no console in the "Metro*" interface. There is still a command prompt on the desktop and that has not changed from Windows 7. This is not going to allow you to run a "Metro*" app, however - it is a command prompt.
I think you may need to do a bit of research into what the "Metro*" UI is, and what it is not.
* This UI is no longer called "Metro", but I have referred to it as such to avoid clouding the issue.
You can use a console if you need that in Windows 8, and your console applications will continue to work. But this is not Metro.

Unkillable processes often hang for a long time

Since re-installing Windows 7 Ultimate 64-bit SP1, sometimes processes take a long time to close. This happens most frequently when launching them from VS2010, but it's not limited to that. A common case is a Windows app with a console (/SUBSYSTEM:console) that appears to close correctly, but the console remains open for seconds or minutes. Eventually the "press any key to close" message appears on the console, and the process can be terminated.
How can I diagnose this problem?
I installed Windows 7 Ultimate 64-bit SP1, but this time the vanilla (not N) version
The only driver I manually installed is the NVIDIA display driver, but I've tried multiple WHQL versions
The symptoms closely match the question at
Visual studio debug console sometimes stays open and is impossible to close Even non-console apps are affected, however.
Both native and managed applications suffer from this.
WRONG: I believed only 32-bit processes were affected, but 64-bit ones also suffer.
if a debugger is already attached, and I break while the process is waiting, the debugger
says:
The process appears to be deadlocked (or is not running any
user-mode code). All threads have been stopped.
I can't attach a debugger to a process while its in this state
I can't kill these zombie processes from Task Manager or
ProcessExplorer, even when closing all handles that refer to said
processes. (I can't close lsass.exe's handles, though)
ProcessExplorer says that the hanging function of the only thread
that the each hung process has is ntdll!RtlDosSearchPath_Ustr.
Most of the time I have to close Visual Studio completely to allow
the zombie processes to close.
The last event that Process Monitor sees at the hang in each case is
a Thread Exit, which succeeds, and it looks like the exit takes the
normal amount of time. When the process finally closes, no events
show up.
LiveKd doesn't show anything when I follow the steps outlined at
http://blogs.technet.com/b/markrussinovich/archive/2005/08/17/unkillable-processes.aspx
It seems like a bad driver is the culprit, so I'm going to reinstall Windows soon.