I am trying to create an extension where each window of chrome has its own session. We used incognito earlier, but the problem is that while the main window and the incognito window have separate sessions, the session is shared between the various incognito windows.
Is there any way of configuring chrome to use a separate session every time an incognito window is opened?
Your goal will be start a Chrome instance with a new user data directory. The cookies will be isolated in each instance.
In the extension to implement a way to reach the same goal as this command on cmd:
chrome.exe --user-data-dir="C:\temp\user1"
I had a similar problem where i want to use google chrome for browsing and debugging for work and chrome is pretty original when it comes to sessions. I wrote this small batch script to duplicate the default profile, clear session information and then use the new profile. Old duplicate profiles are also cleared before the new ones are created. The result is a new session with all the old profile stuff.
#echo off
rem folder prefix for the new profile folder
set folderNameStart=profile_
rem generate and format the date creating the new folder name
For /f "tokens=1-6 delims=/ " %%a in ('date /t') do (set mydate=%%c%%b%%a)
For /f "tokens=1-2 delims=/:" %%a in ('time /t') do (set mytime=%%a%%b)
set folderName=%folderNameStart%%mydate%%mytime%%random%
rem set the profile path and the folder destination as well as the directory to
delete
set profilePath="C:\Documents and
Settings\%USERNAME%\AppData\Local\Google\Chrome\User Data\Default"
set profileDestination="C:\Documents and
Settings\%USERNAME%\AppData\Local\Google\Chrome\User Data\"%folderName%
set profileLocation="C:\Documents and
Settings\%USERNAME%\AppData\Local\Google\Chrome\User Data\"
rem iterate through directory and delete all the existing profile folders
CD %profileLocation%
echo %profileLocation%
for /D /r %%G in ("%folderNameStart%*") do rmdir /q /s "%%G"
rem this will copy the old profile directory
echo D | xcopy %profilePath% %profileDestination%
rem delete the session storage and its contents if its exist
rmdir /q /s "C:\Documents and Settings\%USERNAME%\AppData\Local\Google\Chrome\User
Data\%folderName%\Session Storage"
rem start google chrome with the new profile folder
start "Chrome" "C:\Program Files\Google\Chrome\Application\chrome.exe" --profile-directory="%folderName%"
To make it work need to know difference between open "new window" in chrome, if there no difference then no way to do it in that case. Another way if know what difference when use incognito mode and use it to add in chrome "Open tab in new window pofile 1".
Related
I need to close all windows of a specific Chrome profile. Suppose I execute:
chrome.exe -remote-debugging-port=4000 --user-data-dir=F://chrome
in cmd/bat to open a new Chrome profile. I need to close this specific Chrome profile from cmd/bat.
I have tried this:
taskkill /IM chrome.exe -remote-debugging-port=4000 --user-data-dir=F://chrome
but it's not working.
You can accomplish this using the batch file below:
for /f "tokens=3 delims=," %%a in ('wmic process where "caption='chrome.exe'" get processID^,commandline /format:csv ^| FIND "-remote-debugging-port=4000 --user-data-dir=F://chrome"') do set _pid=%%a
taskkill /f /pid %_pid% /t
Explanation
wmic process where "caption='chrome.exe'" get processID^,commandline /format:csv lists all chrome.exe processes with the command line used to launch them and the process ID that we will use to kill it.
Piping (|) this into FIND "-remote-debugging-port=4000 --user-data-dir=F://chrome" will return only the chrome.exe process started with the command you used.
for /f "tokens=3 delims=," %%a in ("...") do set _pid=%%a will set the _pid environment variable to the process ID of the process we want to kill.
The wmic command combined with the find command should only give us a single result. If you used the command multiple times, then this will only find the process ID of the last process in the list.
taskkill /f /pid %_pid% /t:
/f forces the task to end, because otherwise Chrome will remain open.
/pid %_pid% will supply the process ID we got in the for loop.
/t tells taskkill to kill the entire process tree.
Since every Chrome tab and extension runs in its own process, we want to make sure these get killed as well.
I need to check for the chrome browser in any Windows system by running a .bat file. The batch file should be able to check if Chrome browser is installed in the system. if its installed want to store the path in a variable and use that.I am creating chrome kiosk app..so need to find the chrome path dynamically.Please help me
start "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --kiosk --fullscreen --incognito "website url"
After our discussion in chat, we found that if chrome is not installed, it will not launch. therefore simply use:
start "" "chrome" --kiosk --fullscreen --incognito "https://www.netflix.com/"
We need to ensure that all other chrome windows are closed as it will not open kiosk mode if chrome is already open.
That means if chrome is not found by default using start it is not installed.
Older tries:
This batch file is assuming chrome is installed correctly:
for /F "delims=" %%a in ('where chrome') do (
start "" "%%a" --kiosk --fullscreen --incognito "website url"
)
pause
Once you confirmed that it is working, simply remove echo from the last line to actually perform the start.
The next option, seeing as where might not work is too search for the file.
pushd C:
cd\
for /F "delims=" %%a IN ('dir /b /a-d /s chrome.exe') do (
start "" "%%a" --kiosk --fullscreen --incognito "https://www.netflix.com/in/"
)
pause
The simple solution is:
start "" chrome.exe --kiosk --fullscreen --incognito "website url"
It is necessary to specify an empty title with "" or command START interprets the first double quoted string as optional title string. Run in a command prompt window start /? for help on this command and its options.
The reason for starting successfully Chrome without full path and without its folder path being included in environment variable PATH is explained in answer on Where is START searching for executables?
chrome.exe is (usually) registered correct according to guidelines of Microsoft for Application Registration. So START is capable finding the path of Chrome application itself.
Solution with first checking if Chrome is installed and registered at all:
#echo off
%SystemRoot%\System32\reg.exe query "HKLM\Software\Microsoft\Windows\CurrentVersion\App Paths\chrome.exe" >nul 2>&1
if not errorlevel 1 start "" chrome.exe --kiosk --fullscreen --incognito "website url"
I am trying to write a batch file to force Google Chrome to Update. If I use the following it is close however the batch file below takes out the : and shows a This Site Can't Be Reached notification:
#echo on
start chrome.exe \chrome://chrome
pause
If I had a batch file to open chrome:chrome in a startup page that would be helpful as well.
You could use the profile manager and create a user/profile with chrome://chrome as the start page. Or manually/per batch create a copy of the preferences file in "%USERPROFILE%\AppData\Local\Google\Chrome\User Data\Default" and switch between two versions of the file.
The following batch will just create a backup with datetime appended to the name to start with.
#Echo off
:: GetISODT
for /f "tokens=1-3 delims=.+-" %%A in (
'wmic os get LocalDateTime^|findstr ^^[0-9]'
) do Set _DT=%%A
Pushd "%USERPROFILE%\AppData\Local\Google\Chrome\User Data\Default"
copy Preferences Preferences_%_DT%
start chrome
I'm creating a batch to automate setting up new computers and one of the programs is AVAST. When I install avast silently, it installs chrome as well. Chrome isn't a program that I'm wanting to put on and it seems there is no workaround. So now I'm trying to make it uninstall chrome silently after AVAST but it just opens a new cmd window instead of running the exe.
#echo off
CD /d "C:\Program Files (x86)\Google\Chrome\Application"
for /r %%f IN (setup.ex?) DO (
START /WAIT "%%f --uninstall --force-uninstall --multi-install --chrome --system-level"
)
pause
Moving the end quotation to the end of %%f just gives an error that --uninstall isn't an existing file.
I've tried this on multiple PC's.
Not sure your still looking for an answer, but I was able to make your batch work.
CD /d "C:\Program Files (x86)\Google\Chrome\Application"
for /r %%f IN (setup.ex?) DO (
"%%f" --uninstall --force-uninstall --multi-install --chrome --system-level
)
This may not be the answer... but it's too long for a comment! Are you certain that you must instqall Chrome? How did you install AVAST? Can we see the command line? If you used some kind of answer file perhaps it can be modified or perhaps you can pass arguments to your install command. Try doing the command with /? to see if you get choices. According to this you do have a choice. https://blog.avast.com/tag/google-chrome/
"As we get close to our launch date for our new Avast! Free Antivirus, version 5 we have an exciting new agreement with Google to announce. Starting in mid-November, we will be giving our new users an option to install Google Chrome when installing Avast. And to be clear here since I think some readers were reading too much into this entry. We are not forcing Chrome on users. It is entirely up to the user–to download/install is entirely up to the user and nothing is hidden."
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