How to launch a non-background process from a Windows Service? - windows-services

I have a Windows Service written in C# that launches an instance of the Google Chrome browser using PuppeteerSharp. See the launching code below:
string[] chromeArgs = { "--remote-debugging-port=9222" };
Browser browser = await Puppeteer.LaunchAsync(new LaunchOptions()
{
ExecutablePath = "C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe",
DefaultViewport = null,
Args = chromeArgs,
Headless = false // <-- this is important!
});
Even though I am launching the browser in non-headless mode, I don't see the Chrome browser actually being launched on my machine. I have confirmation that the browser does actually get launched because I see it show up in Task Manager.
I suspect that the Chrome browser is not visible because it is being launched from a Windows service which is a background process, so Chrome is automatically being launched as a background process. Is it possible to launch Chrome as a non-background process so I can see it? And if so, how?

I suspect that the Chrome browser is not visible because it is being launched from a Windows service which is a background process, so Chrome is automatically being launched as a background process. Is it possible to launch Chrome as a non-background process so I can see it? And if so, how?
Win32 services run in a separate session from user-visible applications. Among other reasons, this prevents a security vulnerability known as a shatter attack. So it's not just on a different desktop; it's in a different desktop, which is in a different Windows station, which is in a different user session.
While there is a hack you can put in that allows displaying a UI from a Win32 service, that hack should not be used. It requires lowering the security of the entire system, additionally lowering the security of that service in particular, and may stop working with any future Windows Update.
The proper response to "how do I show a UI from a Win32 service" is "you don't". There are a couple of alternatives:
Do you really need a Win32 service? Perhaps it should just be a regular app that is auto-run on login? Usually, Win32 services are used because they can run without a login, but in that case, I'd have to ask where exactly would you show the UI if there's no user logged in? So first, consider whether your application should really be a Win32 service or not.
If you do really need a Win32 service, and you need to show a UI, then the proper architecture is to split the existing app into a Win32 service and a separate executable that runs on login. When the Win32 service wants to display a UI, it uses some form of inter-process communication to tell the autorun application to display the actual UI.
Note that with option (2), you'd also need to decide how to handle the situation where there are multiple logged-in users (e.g., Remote Desktop sessions), and determine which session you want to display the UI on.

Related

Disable all service workers if not in pwa mode

We have an angular webapp which should work offline only if used as standalone web app (pwa), but not in the "normal" browser mode. Only very few users need the offline feature, but when angular pwa is enabled, all users will get the "last cached" version of the app and we have to display an alert and reload the page if there are software updates (which happens quite often).
We want the website to ignore all service workers, only when used as installed standalone web app the service workers should drop in.
Is that possible? I could not find any solution so far.
I found a solution myself:
it works, by setting the enabled flag conditionally:
ServiceWorkerModule.register('ngsw-worker.js', {
enabled: environment.production &&
(navigator['standalone'] || window.matchMedia('(display-mode: standalone)').matches),
}),

How to remote desktop to an iOS device, a.k.a. how do Mobile Device Farms work?

I have been trying to understand how Mobile Device Farms like DeviceConnect, AWS Device Farm, SauceLabs, etc. get to remote control iOS devices, but I can't find anything on the subject. They get to do it without jailbreaking, which baffles me even more.
I love these kind of projects, because at the moment it seems undoable, but I know that it is possible ('they' are doing it).
With remote control I mean: seeing the screen of the iOS device on your computer screen and able to touch and swipe with your mouse.
Can someone please point me in the right direction as to how these technically work?
If you're using an iPad (in particular) or an iPhone (if you think you'll be able to make our any detail on the smaller screen) then using remote access to view and control what's on your friend's Mac is a good option. And the best way to remote-access a Mac from an iPad is to use Google's free Chrome Remote Access service, which lets you remotely use Mac programs from an iOS device.
It's quite an involved process to set it up the first time, but easy if you want to do it again in future. You'll need the Google Chrome web browser for Mac, and a Google account.
Here is link for Chrome Remote access
https://chrome.google.com/webstore/detail/chrome-remote-desktop/gbchcmhmhahfdphkhkmpfmihenigjmpp?hl=en
Open Chrome and go to Chrome Remote Desktop on the Chrome Webstore. Click Add to Chrome, then Add App. Click Allow, then Continue.
I will give you one approach and small explanation .
You will need to create application with all possible permissions at first also implementation handlers functions .
For example :
Works with files
Real native Socket connections (not http protocol) + need to have some main server signalling (domain or static ip).
Handle remote touch trigger (main problem for real remote/iOS)
Background part experience
Your app need to be non-Market app (more likely).
You can make Application with all possible options that apple give us.
What can you do remote with your app : -control camera/ Mic read geo data , work with galleries , delete or create files . Socket will be communication line .
Also app must initially started and make (on user request) always allow all permissions .
Use camera :
Send with socket some command example ( openCamera ) . AFTER receive this string perform action for opening camera .
If you can fix programability triggering touch events you can make remoteIOS.
More data links :
Q/A send remote events
Q about touch events
Q/A about Permisions
Sorry for the first quick answer,
All of these: DeviceConnect, AWS Device Farm, SauceLabs use Appium in order to control devices.
The component that execute the command is the WebDriver.
Appium have different WebDriver implementation in order to execute operations to different device.
The iOS WebDriver can be found here: https://github.com/appium/appium-ios-driver.
The protocol in use is the JsonWireProtocol.
more details can be found here:
http://appium.io/,
http://www.seleniumhq.org/
Regards

How do I prevent Mobile Safari from accessing the network for a cached webapp?

I have a simple web app that I want to use locally (i.e. I don't want it to ever access the network). All the code is packaged according to the Safari Web Content Guide. I was successful in downloading my web app to my iPhone. I noticed, though, that even though my web app doesn't connect to anything remotely, there will be a network access (the network access indicator fires).
I suspect that iOS is checking to see if the web app is fresh (i.e. checking the cache manifest to see if it needs to update any files). Is there a way to prevent this? It really screws up the user experience.
The never-ending network spinner is a bug in iOS; you won't be able to get around it with a web app:
http://www.devthought.com/2012/09/22/understanding-the-ios6-ajax-bugs/

How do I get a desktop notification from a web app?

I need to create a web app for a client, and one of the requirements is whenever an event is triggered there should be some desktop notification in Windows XP/7 that tells them of the event. Similar to the balloon that pops-up when a new file is added to a folder in Dropbox.
I am using Rails for the web app, but have never done any desktop development. What should I be looking at?
Would this: Growl Notifications from a Web Server
plus Growl for windows meet your needs? http://www.growlforwindows.com/gfw/developers.aspx
It may be worth looking at Noti.
This tool allows web apps to push notifications to a small app running on OS X, Windows and Linux.
Would RSS-enabling the application, coupled with a RSS widget on the desktop, suffice? This has a few drawbacks - for example, it requires setup on the workstations and is not immediate. But it is non-proprietary.
If this is a Windows environment, perhaps the application could use the Windows command msg.exe to pop up an alert box (assuming Windows messenger service is enabled on the workstations).
You can use Telegram (desktop portable version included) with TeleNotify gem. Downside is, your app must have HTTPS. But with CloudFlare you can get your app working with SSL for free, even without changing your source code.

Communication Handling using Service in Blackberry 4.5

I am developing an app. (like google talk) which at phone boot-up starts a background service which is continuously running. This service interacts with UI (means any request to server is first sent from UI to service & from service to server) & any response is sent to UI through service.
What i know to start background service at boot up is "Create an alternate entry point and use that to start the background service. "
right click the project properties then go to Application tab, then check "Auto run on startup" / "System Module"
is it right?
In Android u can achieve this Service using system-defined Service class. How to achieve this in Blackberry 4.5? I want to do it (UI & Service) in one project.
Any solution?
Thanks for the reply.
I got a link for
"How To - Setup an alternate entry point for my application"
is it the right solution for starting Service?
I want the app. like email app. which will notify u when an incoming mail comes (like even though ur main application is minimized then also ur service is running in background which will continuously check for any incoming mail & will notify the main UI application through any app icon change)
So for this is there any class like Service class which will start at boot-up or "Setup an alternate entry point for my main UI application" is the only solution for this?
Thanks for the reply..
I read this GlobalEveltListener & tried for handling the communication between the 2 apps (Service app. & UI app.) by starting the Service at auto-startup.
I m using the "Persistent Store" & accessing it in both the apps. But the Persistent Store name should be unique otherwise it gives "Linker error: Cannot start the Service app. as Persistent Store is multiply defined." But I have to access the Persistent Store the both the apps to make some database calls.
So now i m trying for handling the Service by putting both apps in one project. So that the Persistent Store will be unique.
How to achieve this communication between Service & UI in one project?
You only need an alternate entry point if you want the program to behave in both the service mode, starting at boot and running in the background; and in application mode, having an icon in the home screen that the user can click to begin interacting with your software. In that case you need to have an entry point that tells the program "you are starting automatically at boot up", and one that tells the program "you are starting in response to user interaction".
There are other ways to handle this. If your application makes itself available to the user through ApplicationMenus, then you make the one and only entry point "Auto Run" and "System Module" so that it starts on boot, registers the menus and does not display an icon.
You can also use one entry point set to "Auto Run" but not a system module so the icon is displayed and detect the start on boot case using the ApplicationManager.inStartup() method.
The method you describe does work well for the type of application you are developing. It simplifies the initialization by allowing you to specify different arguments to the program in each entry point.
Please see the answer I have given earlier to a different question here. This essentially is an IPC mechanism between two running processes.

Resources