chrome command line parameter to clear cache - google-chrome

in Chrome there is an option in the settings that the cookies and cache are deleted on exit.
is there also a command line parameter to run this on a fullscreen kiosk if required? or that the browser is always started with a cleared cache?

Related

Failed to start native messaging host on Windows, "COMSPEC is not set"

I have a chrome extension that communicates with a native messaging host to get some data.
The issue is, when I launch the Chrome browser via the shortcut or via the pinned shortcut in the taskbar, the extension is not able to connect to the host. I always get the error:
Failed to start native messaging host.
However, if I launch the chrome.exe via command prompt, everything works fine.
Things I tried with no success:
The taskbar shortcut has no extra flags. The target field has the
following value: "C:\Program Files(x86)\Google\Chrome\Application\chrome.exe"
I tried with the registry under HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Google\Chrome\NativeMessagingHosts\com.company.extension
I tried with the registry under HKEY_LOCAL_MACHINE\SOFTWARE\Google\Chrome\NativeMessagingHosts\com.company.extension
I tried with the registry entry under
HKEY_CURRENT_USER\Software\Google\Chrome\NativeMessagingHosts\com.company.extension
Tried launching the chrome.exe as administrator from the file explorer.
Update:
I added the flag --enable-logging --v=1 to the shortcut to enable logging and when I launch it I get the following output in the console:
[11036:4160:0302/113902.866:ERROR:native_process_launcher_win.cc(140)] COMSPEC is not set
[11036:11856:0302/113902.882:ERROR:native_process_launcher_win.cc(140)] COMSPEC is not set
Update
Upon investigating the chrome.exe process via Process Monitor, I found that there is no COMSPEC environment variable available to it when it is spawned via explorer.
Is there anything else that I can try or something that I am missing here?
As mentioned in the log, Chrome stumbles to start an external process, since COMSPEC, an environment variable pointing normally to cmd, is unset:
[11036:4160:0302/113902.866:ERROR:native_process_launcher_win.cc(140)] COMSPEC is not set
The behavior is different for launching Chrome from cmd itself, since it sets the variable for itself (ans spawned processes).
This can be confirmed by inspecting the Chrome process with Process Explorer.
One can run rundll32 sysdm.cpl,EditEnvironmentVariables as admin (e.g. from admin command line) to open the environment variable settings.
Alternatively, the dialog can be navigated to from Control Panel > System and Security > System > Advanced system settings > Advanced > Environment Variables...
ComSpec is usually set in System variables to
C:\WINDOWS\system32\cmd.exe
Adjust as necessary for your system install. For this setting to apply, you need to log out and log back in, or better yet restart the system.

Locally installed extension disables itself?

I'm testing an extension for Chrome and it's unpacked to a local directory. I installed it with the "load unpacked extension" button in settings. For some reason, after an unspecified amount of time, it just disables itself. I can go back into settings and re-enable it, but it does this all the time.
I'm using Ubuntu if it matters.
Chrome extension can call chrome.management.setEnabled(chrome.i18n.getMessage("##extension_id"), false); to disable it self, so if you want to stop this behavior, you could take a look at the extension code and comment out this block of code.

Run chrome in fullscreen mode on Windows

I want to configure my computer to launch Google Chrome Windows start up. It should start in full screen mode and open some web page.
I tried to run Chrome with the following command line:
chrome.exe --start-fullscreen --app=https://google.com
However Chrome opens in windowed mode, not in full screen mode.
Is there any way to run chrome in full screen mode?
Update 03-Oct-19
new script that displays 10second countdown then launches chrome/chromiumn in fullscreen kiosk mode.
more updates to chrome required script update to allow autoplaying video with audio. Note --overscroll-history-navigation=0 isn't working currently will need to disable this flag by going to chrome://flags/#overscroll-history-navigation in your browser and setting to disabled.
#echo off
echo Countdown to application launch...
timeout /t 10
"C:\Program Files (x86)\chrome-win32\chrome.exe" --chrome --kiosk http://localhost/xxxx --incognito --disable-pinch --no-user-gesture-required --overscroll-history-navigation=0
exit
might need to set chrome://flags/#autoplay-policy if running an older version of chrome (60 below)
Update 11-May-16
There have been many updates to chrome since I posted this and have had to alter the script alot to keep it working as I needed.
Couple of issues with newer versions of chrome:
built in pinch to zoom
Chrome restore error always showing after forced shutdown
auto update popup
Because of the restore error switched out to incognito mode as this launches a clear version all the time and does not save what the user was viewing and so if it crashes there is nothing to restore. Also the auto up in newer versions of chrome being a pain to try and disable I switched out to use chromium as it does not auto update and still gives all the modern features of chrome. Note make sure you download the top version of chromium this comes with all audio and video codecs as the basic version of chromium does not support all codecs.
Chromium download link
#echo off
echo Step 1 of 2: Waiting a few seconds before starting the Kiosk...
"C:\windows\system32\ping" -n 5 -w 1000 127.0.0.1 >NUL
echo Step 2 of 5: Waiting a few more seconds before starting the browser...
"C:\windows\system32\ping" -n 5 -w 1000 127.0.0.1 >NUL
echo Final 'invisible' step: Starting the browser, Finally...
"C:\Program Files (x86)\Google\Chromium\chrome.exe" --chrome --kiosk http://127.0.0.1/xxxx --incognito --disable-pinch --overscroll-history-navigation=0
exit
Outdated
I use this for exhibitions to lock down screens. I think its what your looking for.
Start chrome and go to www.google.com drag and drop the url out onto the desktop
rename it to something handy for this example google_homepage
drop this now into your c directory, click on my computer c: and drop this file in there
start chrome again go to settings and under on start up select open a specific page and set your home page here.
Next part is the script that I use to start close and restart chrome again in kiosk mode. The locations is where I have chrome installed so it might be abit different for you depending on your install.
Open your text editor of choice or just notepad and past the below code in, make sure its in the same format/order as below. Save it to your desktop as what ever you like so for this example chrome_startup_script.txt next right click it and rename, remove the txt from the end and put in bat instead. double click this to launch the script to see if its working correctly.
A command line box should appear and run through the script, chrome will start and then close down the reason to do this is to remove any error reports such as if the pc crashed, when chrome starts again without this it would show the yellow error bar at the top saying chrome did not shut down properly would you like to restore it. After a few seconds chrome should start again and in kiosk mode and will point to what ever homepage you have set.
#echo off
echo Step 1 of 5: Waiting a few seconds before starting the Kiosk...
"C:\windows\system32\ping" -n 31 -w 1000 127.0.0.1 >NUL
echo Step 2 of 5: Starting browser as a pre-start to delete error messages...
"C:\google_homepage.url"
echo Step 3 of 5: Waiting a few seconds before killing the browser task...
"C:\windows\system32\ping" -n 11 -w 1000 127.0.0.1 >NUL
echo Step 4 of 5: Killing the browser task gracefully to avoid session restore...
Taskkill /IM chrome.exe
echo Step 5 of 5: Waiting a few seconds before restarting the browser...
"C:\windows\system32\ping" -n 11 -w 1000 127.0.0.1 >NUL
echo Final 'invisible' step: Starting the browser, Finally...
"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --kiosk --overscroll-history-navigation=0"
exit
Note: The number after the -n of the ping is the amount of seconds (minus one second) to wait before starting the link (or application in the next line)
Finally if this is all working then you can drag and drop the .bat file into the startup folder in windows and this script will launch each time windows starts.
Update:
With recent versions of chrome they have really got into enabling touch gestures, this means that swiping left or right on a touchscreen will cause the browser to go forward or backward in history. To prevent this we need to disable the history navigation on the back and forward buttons to do that add the following --overscroll-history-navigation=0 to the end of the script.
It's very easy.
"your chrome path" -kiosk -fullscreen "your URL"
Example:
"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" -kiosk -fullscreen http://google.com
Close all Chrome sessions first !
To exit:
Press ALT-TAB > hold ALT and press X in the windows task. (win10)
I would like to share my way of starting chrome - specificaly youtube tv - in full screen mode automatically, without the need of pressing F11. kiosk/fullscreen options doesn't seem to work (Version 41.0.2272.89). It has some steps though...
Start chrome and navigate to page (www.youtube.com/tv)
Drag the address from the address bar (the lock icon) to the desktop. It will create a shortcut.
From chrome, open Apps (the icon with the multiple coloured dots)
From desktop, drag the shortcut into the Apps space
Right click on the new icon in Apps and select "Open fullscreen"
Right click again on the icon in Apps and select "Create shortcuts..."
Select for example Desktop and Create. A new shortcut will be created on desktop.
Now, whenever you click on this shortcut, chrome will start in fullscreen and at the page you defined. I guess you can put this shortcut in startup folder to run when windows starts, but I haven't tried it.
Running chrome.exe --start-fullscreen --app=https://google.com will not get you Chrome in fullscreen, but in kiosk mode.
However, running chrome --start-fullscreen --app=https://google.com (notice : it's chrome instead of chrome.exe) worked in my case.
You can also add --disable-session-crashed-bubble to eliminate the errors that come up after a crash or improper shutdown.
Right click the Google Chrome icon and select Properties.
Copy the value of Target, for example: "C:\Users\zero\AppData\Local\Google\Chrome\Application\chrome.exe".
Create a shortcut on your Desktop.
Paste the value into Location of the item, and append --kiosk <your url>:
"C:\Users\zero\AppData\Local\Google\Chrome\Application\chrome.exe" --kiosk http://www.google.com
Press Apply, then OK.
To start Chrome at Windows startup, copy this shortcut and paste it into the Startup folder (Start -> Program -> Startup).

Prompted by "Google Chrome didn't shut down correctly.... "

Using Google Chrome 38.0.2125.111 m in a Windows 7 environment. It is launched by a batch file & set to go to a specific (internal) URL. The Windows environment is going to be locked down, permitting only a handful of options available to the user.
Chrome is being used because IE will be accessing a different site. Without going into boring detail, using both sites on a single browser allowed a user to access an account that wasn't theirs. Both browsers will be launched using one of two batch files. The Chrome batch file supplies the username & password to bypass a login screen on that application.
To keep from opening multiple windows in Chrome, the following batch file is used:
taskkill /f /t /im chrome.exe > NUL
ping -n 3 127.0.0.1 > NUL
START /max chrome "http://myinternalwebsite?uid=x&pwd=y"
Taskkill is used to close chrome (/f = force /t = terminates process & any child ones /im = image name).
If the Chrome session is closed (using the X at the upper right corner of the screen), the batch file works fine. However, if there is already a chrome instance running, we get the yellow bar with the frowning folder & a message saying:
Google Chrome didn't shut down correctly. To reopen the pages you had
open, click Restore.
I have tried several command line options when launching Google Chrome, but none will keep the message from displaying. Ones I have tried are:
--disable-restore-session-state
--disable-session-crashed-bubble
--incognito
among others. I've experimented with some of the settings in Chrome, but none have (yet) worked. The --incognito option works - sort of. It keeps blocking plugins, one of which is Silverlight - one of the chief components for the website to function. Even though it does get rid of the message, it leaves the site not functioning properly.
The intent on using Taskkill to flush any existing Chrome sessions was to prevent the user opening up a dozen different Chrome instances of the same thing.
Is there any way to keep a user from opening multiple instances of Chrome that won't leave Chrome thinking it didn't close properly? Given the user restrictions, I'm not sure that a script/batch file to edit the Preferences file in the Chrome folder will work. An extension may be an option, but a third party application will not be.
Would appreciate any thoughts or assistance.
Thanks!
Chromium writes exit status into Preferences file. When it starts it writes Preferences file with:
"exited_cleanly": false
and upon clean exit writes Preferences file with:
"exited_cleanly": true
To prevent message about unclean shut down make sure that you have "exited_cleanly": true written in your Preferences file
On my Linux kiosk running on Raspberry Pi this sed command line added to /etc/rc.local fixes issue permanently:
sed -i 's/exited_cleanly\":\ false/exited_cleanly\":\ true/g' /home/pi/.config/chromium/Default/Preferences

Chrome won't allow local camera access

I'm trying to test out some code for accessing a webcam on an HTML page and Chrome doesn't seem to allow me to. I made an exception for the file and yet everytime I reload (which it tells me will put the settings in effect) it goes back to blocking it
Go to:
chrome://flags/#unsafely-treat-insecure-origin-as-secure
Add your url there and enable this flag, relaunch and it should work.
You can open chrome with the flag disable-web-security
For Mac, in terminal:
open -a /Applications/Google\ Chrome.app/ --args --disable-web-security
For a PC in console:
chrome.exe --disable-web-security