how to run batch file in chrome - google-chrome

I tried using very simple HTML to create several links to several batch files on my server that are intended to run when users click on the links. Using Chrome, every time I click on one of those files my browser displays the script itself (even though its a .bat) and doesn't actually run the script. Internet Explorer runs it every time, however all the users on the network use Chrome for web browsing.
Is there any way to force Chrome (preferably through HTML or VB or some other scripting on the page itself rather than change all of the users' browser settings) to run these batch files when the user clicks on the link?

The answers given so far - that it's "not possible" - are incorrect or outdated. Using Chrome Apps you can call executables (called "hosts") if they are registered with Chrome. Of course a Chrome App is a client application so you need to distribute it.
See https://developer.chrome.com/extensions/nativeMessaging#examples

HTML, JS on browser cannot run shell command, command line. You have to implement server script to execute your bat file then call it from HTML, JS via Ajax or direct link.

Related

Load remote JS script in Content script for Chrome extension

I have a chrome extension. I have a lot of code in the content script.
Nowadays Google takes a lot of time to publish the extension. About 10-15 days due to covid etc.
I have the same extension on Firefox too where I load all remote code through script injection.
How can I do the same with the Chrome extension? When I try to load the remote script it gives me the following error.
This document requires 'TrustedScript' assignment.
I think Chrome became stricter with the release of version 83.
Also as per ChromeStore support, a wrapper that loads the code remotely is the way to go. But I can't find suitable documentation or a sample code. Questions found on Stackoverflow are about 4-5 years old at minimum.
Also, some of the guys are of opinion that the Chrome store will reject the extension if we inject remote script. But following image belongs to the submission extension UI of Chrome Developer Dashboard.
And you can clearly see that I is saying that does your app requires remote code.
Any help is highly appreciated.

Are browsers accept plugins today or just extension?

I don't want to create extension because they are limited.
I would like my code to execute on any page from the browser.
I have read that creating plugin is deprecated for security reason (NPAPI).
There is Emscripten that looks like executed only on server.
Is there a way to code and execute program from the computer to access and modify browser page content?
You can look TamperMonkey extension. That extension provide user made scripts and run.
Chome Web Store Tampermonkey

Open local files(file://) using Chrome

I have an page with some forms. All the links work fine in IE. They open in a new tab nicely when the hyperlink is click by the user; however, I realized that when Chrome is use the link doesn't open. I keep clicking but nothing opens. The only way of opening the file is copying the hyperlink, opening a new tab in Chrome, paste and go.
Form1
Is this something that browser do? Because I tried it with FireFox and doesn't work either?
It there a way of going around? without installing anything in the browser? Because my user loves Chrome.
Thank you in advanced for the responses.
You can't access to files outside your server or "SandBox", sandbox include the files that user push to the browser or to your server.
If the access from browser to a pc files from web pages was possible, it would be a security problem.
The answer is that you can't with your approach and more importantly you shouldn't. Chrome behavior is in fact the right behavior and it protects you from having malicious users and/or scripts accessing your local resources.
The FILE protocol will access local or defined network named resources which will not be available to a remote user that visits the same page. In other words, you may have outsideserver mapped as a network resource/drive but someone else will not (This does not apply to IPs)
Here's what you can do:
Move the code to a server side script(php, asp, etc) and stream the file back out. Found a quick example here on SO. I did not verify it though. Streaming a large file using PHP
Install a webserver on outsideserver and map a new site to the shared folder. You can then reference it via http (http://outsideserver.com/form1.pdf)
Use the below extension for chrome. It will work.
Enable local file links
Below both options are working and tested.
Link 2
Link 3

Google Chrome --new-window switch ignores --window-position and --window-size

I'm trying to control the size and position of newly spawned Google Chrome windows via the command line (through C#.)
My command line ends up looking like:
--new-window --window-position=100,100 --window-size=800,600 www.UrlToOpen.com
However, the new window just opens over top of where the last Chrome window was started.
The end result I'm looking for is to be able to start multiple instances of Google Chrome, in separate windows, with a specific location and size. The only way I've been able to do this so far is by specifying that each instance is to have it's own --user-data-dir. However, this is not ideal given how many extensions a user may have installed, and it would not be the best user experience.
Does anyone have any suggestions?
If Chrome is not programmed to allow this, you only have one option.
Create the process and keep the process object.
Use Process.MainWindowHandle to get the newly created window (you might need to use a loop and Process.Refresh, or Process.WaitForInputIdle)
Use the SetWindowPos native function to position the window wherever you want it.
Native hooks could be used to detect creation of the window, but that requires you to create an unmanaged DLL.
I have another idea for you, why not use a chrome extension for handling the positioning.
Background: We had related difficulties. Internal webapp that opens multiple documents in windows, and need to be placed in other monitors.
The javascript does not support this, for security reasons and only a native extension can properly work with the tabs/windows objects.
Therefore, we have created an open source chrome extension for doing exactly that: flexible windows position across multi-monitor setups.
Perhaps more interest to you would be the feature to use predefine templates. The template file is located in any webserver you like and therefore can be easily share across different users.
The chrome extension is called "MultiWindow Positioner" and its complete free. You can get it at the chrome store here
The actual source code you find in github in the project chrome-multiwindow-positioner
Disclaimer: I am the maintainer of the open source (MIT) github project. If there any interesting idea, or comments feel free to share them here.

Running script ... message stays there on some systems/browsers

One of our users is having trouble executing one of ours apps. Whenever they access the script, the "Running script Dismiss" message stays there for a seemingly infinite time.
Are there some plugins in browsers which stop google app script from working correctly? They have tried Firefox on linux and Firefox and Chrome on Mac.
The script can be accessed via this template - https://docs.google.com/spreadsheet/ccc?key=0Al5WvYyk0zzmdDNLeEcxWHZJX042dS0taXJPNXpJMHc , a tool menu will appear named OntoMaton. All four actions in this menu, including the trivial "About" item, are failing/hanging for the user.
We've discovered that the issue is the shared doc does not ask for permission to run on the users machine, therefore the script is unable to run but there should be a warning message for this.
I asked the user to install the app script from the gallery directly then everything worked for them.