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"
Related
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."
I'm trying to test a html file in all browsers. Is there a way using the command line to open all of the .html files in a directory in Internet Explorer, Firefox, Chrome, etc with each file in its own tab in each browser to ensure that the html files are working properly across all internet browsers?
This code I have below opens all of the html files but each in a new window for each browser. I'm trying to consolidate all of the files to stick to one browser window.
#echo off
setlocal
pushd "C:\pathtohtmlfiles"
for %%a in (*.htm *.html) do (
start "Internet Explorer" "C:\Program Files\Internet Explorer\IEXPLORE.EXE" "file://%CD%\%%a"
start "Firefox" "C:\Program Files\Mozilla Firefox\firefox.exe" "file://%CD%\%%a"
start "Chrome" "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" "file://%CD%\%%a"
)
popd
You have to specify a command-line argument that is different for each browser.
#ECHO OFF
SETLOCAL
PUSHD "C:\pathtohtmlfiles"
FOR %%a IN (*.htm *.html) DO (
REM START "Internet Explorer" "C:\Program Files\Internet Explorer\IEXPLORE.EXE" "file://%CD%\%%a"
START "Firefox" "C:\Program Files\Mozilla Firefox\firefox.exe" -new-tab "file://%CD%\%%a"
START "Chrome" "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" chrome:\\newtab "file://%CD%\%%a"
)
POPD
Internet Explorer doesn't have one, so have fun with that. Here are the Firefox command-line arguments and Chrome has no documentation on this.
I'm trying to test a html file in all browsers. Is there a way using the command line to open all of the .html files in a directory in Internet Explorer, Firefox, Chrome, etc with each file in its own tab in each browser to ensure that the html files are working properly across all internet browsers?
This code I have below opens all of the html files but each in a new window for each browser. I'm trying to consolidate all of the files to stick to one browser window.
#ECHO OFF
SETLOCAL
PUSHD "C:\pathtohtmlfiles"
FOR %%a IN (*.htm *.html) DO (
REM START "Internet Explorer" "C:\Program Files\Internet Explorer\IEXPLORE.EXE" "file://%CD%\%%a"
START "Firefox" "C:\Program Files\Mozilla Firefox\firefox.exe" -new-tab "file://%CD%\%%a"
START "Chrome" "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" "file://%CD%\%%a"
)
POPD
I found that I could only start multiple html files in the same window if I called them in the same command, perhaps this will work for you -
#ECHO OFF
SETLOCAL
SET files=
PUSHD "C:\pathtohtmlfiles"
FOR %%a IN (*.htm *.html) DO SET files=%files% "%%a"
START "Firefox" "C:\Program Files\Mozilla Firefox\firefox.exe" %files%
START "Chrome" "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" %files%
POPD
The file:// was unnecessary for me.
I tested the below script is working fine for my Chrome and FF, however, I tried a few ways but still can't figure out the IE - it always to open in a new windows
#ECHO OFF
for /r "C:\pathtohtmlfiles" %%A in (*.htm*) do (
START "Internet Explorer" "C:\Program Files\Internet Explorer\IEXPLORE.EXE" "file://%%A"
START "Firefox" "C:\Program Files (x86)\Mozilla Firefox\firefox.exe" "file://%%A"
START "Chrome" "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" "file://%%A"
)
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".