Targeting active processes in Windows Power Automate actions - power-automate-desktop

I have created an action to shut down several processes. Why? I am using Dragon Pro voice-to-text and Voice Computer in my adaptive technology stack. Unfortunately, the former crashes regularly, and when this happens, it doesn't shut down cleanly. I have the following action in Windows Power Automate, using this trick to listen for a shortcut key.
I tried targeting each process by its ID, but it seems that the ID changes each time the process runs a new. So then I tried by process name, but that doesn't seem to work. How do I properly target these processes?

Can I suggest using a PowerShell script? Using PAD seems like a bit of overkill to achieve such a thing but I guess if it's baked into your entire solution then this will work nicely and we all know there is an action within PAD to run a PowerShell script.
$processes = Get-Process
Foreach ($process in $processes) {
if ( $process.Name -eq "natspeak" ) {
Stop-Process -Name $process.Name
}
}

Related

How to make container installation behave like host machine installation

I'm working with the following:
Docker for Windows v20.10.11
Docker running in Windows container mode
mcr.microsoft.com/windows:1903 base image
Proprietary application installed on top of this base image
Each year we create a Docker image with the latest version of our company's software. However this year's version behaves differently. Host machine installation runs fine. Containerized installation fails to run in certain situations. I can start the application as a simple EXE, for example using the Docker run command. The app will start and show up in "tasklist". However I can't start the app via the COM API, which is a critical requirement. The problem appears to be COM related. Normally we can create COM objects for our software just like for any other application. For example, IE returns a COM object just fine:
Creating these objects for our application works outside containers. However inside the container, our latest installation gives this error:
Access permissions appear to be ok. I tried a couple tests to prove this. First I can install other software like MS Word into a container and create COM objects for that:
Second I tried retrieving + modifying the application's DACL in PowerShell.
Changing access masks or trustees can cause an Access Denied error:
This also appears to confirm the access permissions were Ok by default.
Next I made sure COM is aware of the application. This appears to be fine. I get the same result on host machine and container when running this PS script:
gci HKLM:\Software\Classes -ea 0| ? {$.PSChildName -match '^\w+.\w+$' -and
(gp "$($.PSPath)\CLSID" -ea 0)} | ft PSChildName
The application shows up just like any other. The details show up fine when querying by AppID. LocalServer32 points to the correct EXE:
Some other things I tried:
Querying registry keys. There are 7 keys created when installing our software. These appear identical on host machine install and container install.
Even though permissions appear fine, I still tried logging into the container as alternate users. For example "nt authority\system" is another virtual admin user. I also changed the password of the "builtin\administrator" user to enable logging in with that one. Lastly tried creating new users entirely and adding them to the Administrators user group. All these attempts had the same errors as "builtin\containeradministrator" (default user).
A minor check was ensuring CMD.exe / Powershell is running as x64:
Re-registering the DLLs associated with the installation using regsvr32.
Starting from different base images. https://learn.microsoft.com/en-us/virtualization/windowscontainers/manage-containers/container-base-images. The full Win Server base image behaves exactly the same way regarding errors. The smaller Win Server Core base image is even more problematic, as I can't even start the app's EXE manually using that base. Lastly I tried other tags of the full Windows base image such as 20H2 and 2004. Same result from those. Multiarch or x64 makes no difference.
Included the "Ogawa hack" which was historically needed to make MS Office apps function correctly with COM: https://stackoverflow.com/a/1680214/7991646. It could be necessary for other COM apps too, but didn't help with my specific installation.
Is there anything else I can do to diagnose or solve this COM issue?
There are several things to consider:
The Considerations for server-side Automation of Office article states the following:
Microsoft does not currently recommend, and does not support, Automation of Microsoft Office applications from any unattended, non-interactive client application or component (including ASP, ASP.NET, DCOM, and NT Services), because Office may exhibit unstable behavior and/or deadlock when Office is run in this environment.
If you are building a solution that runs in a server-side context, you should try to use components that have been made safe for unattended execution. Or, you should try to find alternatives that allow at least part of the code to run client-side. If you use an Office application from a server-side solution, the application will lack many of the necessary capabilities to run successfully. Additionally, you will be taking risks with the stability of your overall solution.
The When CoCreateInstance returns 0x80080005 (CO_E_SERVER_EXEC_FAILURE) page describes possible reasons.
If many COM+ applications run under different user accounts that are specified in the This User property, the computer cannot allocate memory to create a new desktop heap for the new user. Therefore, the process cannot start. See Error when you start many COM+ applications: Error code 80080005 -- server execution failed for more information.
Finally, you may find a similar thread here helpful, see Server execution failed (Exception from HRESULT: 0x80080005 (CO_E_SERVER_EXEC_FAILURE)).

Is there a way in LeanFT / UFT Developer to get active element on OS level?

My automation Framework consists of the following: UFT developer V15.0 (previously LeanFT) + Java + Maven + Junit.
UI Tests are executed by Jenkins on a dedicated VM (OS = Windows 10).
Many of my test cases include actual keyboard press, as this is a requirement of the AUT which is a web application.
My problem is that if tests are executed while user is not actually logged in - the cases which require to focus on the browser and press the keyboard - will fail.
When i use RDP to log in to the VM and minimize - tests will still fail.
when I use RDP, login to the VM and keep the screen open - test will focus successfully on relevant field and will pass.
I tried to disconnect using tscon using the below script, but still no use:
for /f "skip=1 tokens=3" %%s in ('query user %USERNAME%') do (
%windir%\System32\tscon.exe %%s /dest:console
)
As per my understanding - the problem seems to be focus.
To try and understand the source of the problem, i would like to try and get the actual active element which is currently in Focus on the OS level, just like getting the active element on browser ("document.activeElement.id").
As UFT developer is able to interact with Windows elements - is there a way to retrieve such info from the OS?
Or alternatively , solution to the original problem (keeping the focus on the running browser) would be great.

ComputerCraft Run Chat Command

I host a server and I was wondering: is there any way to run chat commands through ComputerCraft? I want to be able to run /tps through the ComputerCraft terminal and then have it print out the TPS. Help would be greatly appreciated.
Thanks.
In the new Computercraft 1.7 there is a new type of computer, the Command Computer. It allows the user to run commands the same way as shell.run("mkdir", "foo"). It can only be obtained by ops, and can only directly be controlled (we are talking without using rednet and such) by ops
commands.exec(string command) -- Runs and outputs command output in chat.
commands.execAsync(string command) -- Quietly runs command without output.
Here is the wiki page:
Commands (API)
But if we are talking 1.6.4 (Which almost all modpacks use) there is no "stock" version of doing that.
Hope it helps /Tyrerexus
I believe that you can use this thing called the Chat Box.
http://ftbwiki.org/Chat_Box
It's not part of the default Computercraft, however. It is part of the Misc Peripherals mod I believe.

Forcing a Windows service to fail

Whenever a specific Windows service fails I want to run a program I've created myself. However, I simply can't find a way to make it fail on purpose, so that I can actually test that everything works correctly.
Note that the service in question is not something I've written myself, so I can't make it fail programmatically from inside the code. I wouldn't, however, mind writing a program that can make a service fail.
Of course I would prefer just having a "Make service fail" button somewhere in services.msc ... ;)
The server I'm doing this on is running Windows Server 2012.
If you don't want to use command line :
As an admin open the Windows Task Manager, in the Services tab find the service you want to test. Right click the service and click on Go to process. The selected process (if any) is the one corresponding to your service. Kill this process to simulate a service failure.
Be aware that killing a process this way can lead to problems.
Define "fail". If you want the process to end, just use pskill or a similar tool that can terminate a process elevated (as an admin).

Nant: Process id of a service that is already running

Does anyone know how to get the PID of the process that a windows service is running in from Nant?
I am having file locking problems. I issue a stop command to the service and then try and delete the Windows service's files. However these are quite often locked by the process that the Windows service is running in. I want to find the PID so that I can wait for it to terminate before deleting.
Thanks
You might have to create a custom nant task to do this. However you might want to see about just adding maybe a delay like 1 min or something before you try to replace your files. Might be easier.

Resources