I have a simple Tray icon program that opens a site using
System.Diagnostics.Process.Start("URL")
And it works fine independently, however when a service loads it, it gives a file not found exception when trying to open the URL, and after testing it can open normal extensions, e.g .txt (The service has desktop interaction enabled).
If you Process.Start a URL, it is loading a browser app, which isn't (for Vista/etc) going to display for a service (for the same reasons as your last question).
If you want the app to interact with the user/desktop, it shouldn't be a service - it should simply run when the user logs in. Note that any child-process that your service spawns will also be in the service's session.
If you just want to get data (through code) from the site, use WebClient etc.
Related
I have an app that tests web page layouts in different browsers without requiring the user to download a new browser to their local. Every time when a user opens a new browser to test a page, I want this browser to open in a sandbox to limit the browser's actions in case of coming across any malware or dangerous sites.
How can I do that?
Note: The app is in C#.
You may also want to determine if this will be an acceptable workflow since each launched sandbox will only have the default browser by default. Additional browsers may have to be manually installed, even scripted, but will take time and slow down testing.
Configuring your sandbox:
You may be able to devise a workaround based on creating a .wsb file and populating it with a startup script. Your app can create this file programmatically with parameters and launch it.
https://www.windowscentral.com/how-configure-windows-sandbox-windows-10
Based on that you would probably have something like the following:
<Configuration>
<VGpu>Default</VGpu>
<Networking>Default</Networking>
<MappedFolders>
<MappedFolder>
<HostFolder>C:\FolderThatContainsBrowserInstaller\</HostFolder>
<ReadOnly>false</ReadOnly>
</MappedFolder>
</MappedFolders>
<LogonCommand>
<Command>Powershell.exe -ExecutionPolicy Unrestricted C:\users\WDAGUtilityAccount\Desktop\FolderThatContainsBrowserInstaller\ScriptThatInstallsBrowserAndLaunchesURL.ps1</Command>
</LogonCommand>
</Configuration>
Additional info may be found here: Starting the Windows Sandbox from managed code
You will have to decide what the ScriptThatInstallsBrowserAndLaunchesURL.ps1 actually does, but installing browser to test, then launching it with URL sounds like a fairly simple task.
Using WebView2 browser when a user clicks a link that opens another program, this prompt shows up every time.
Is there a way to suppress this in WebView2?
You can use the NavigationStarting event to cancel navigations to URIs that start with the URI schemes you care about and then do whatever you like with that URI. For example, call ShellExecuteExW, or Windows.System.Launcher.LaunchUriAsync with the URI so that the OS opens the URI.
As Yu Zhou notes this is dangerous if its arbitrary websites opening arbitrary applications as in the case of a web browser. If you're going to skip this security prompt you should ensure that you own the web content or trust the web content in the WebView2 to not be malicious. If you are showing arbitrary URIs or user submitted web content you should not skip the prompt.
I can understand that you want to bypass the prompt, but it's by design and we can't change it. It is designed for security. This prompt is the only thing standing between every arbitrary site on the Internet (loaded inside your browser’s sandbox) and a full-trust application on your computer (running outside of the browser’s sandbox).
The only thing we can do to reduce the pain is to check the "Always allow..." checkbox, so that the prompt won't show at the next time.
My app is Windows based, and there is IE installed. But my app will run in a process which does not like externally-launched applications (like a web browser, when authorizing). Instead, my app will use the host application's web features to display a browser.
The host app takes over the front-end and is a public kiosk-type application, so I have no control over how browsing gets launched. The google drive api automatically launches the default browser (with an affinity toward Chrome, even if not the default... :-/
I cant give code examples, but you need to look into non browser based auth - i.e. server side authentication https://developers.google.com/drive/web/auth/web-server?hl=en
I am trying to write and application on windows where my application shud be prompted to open thru a browser link. how can I do that?
I don't know about second life, but I would register an file extension (like .MyApplication) with my application and create links to a .MyApplication-file on the web site. You an also encode special startup parameters inside that little file.
I just need to be able to open a .NET app (click once) from within an ASP.NET web page, and pass 2 string parameter to the app.
How can I do this? Any example please, with any method to do it. Thank you in advance.
This article explains how to retrieve the parameters from the querystring used to call the ClickOnce app. That should help you to figure out how to compose the URL, along with its querystring containing the parameters you want to send.
You could associate your application with a file extension and then simple generate a text file with your parameters from the web application with this extension and that would be opened by your client application.
Edit: If your click once application is deployed from a web site you could just link to that url. Depending on the click once settings the app could be started from the client if already installed.
There are two ways to deploy a click once app - so it can be launched from the start menu, and so it can be launched from a URL. Assuming you have set the app up as the URL-started one, just have a link on any ASP.NET page (or could be pure html, doesn't matter) to the click once app's URL. When the user clicks it their browser, IIS, and their local copy of Windows will all do the work to get the app launched.