I'm trying to write a batch file to open gmail in incognito and enter my credentials automatically when the pc starts up. Based on this post I have the following:
@echo off
cls
start %ProgramFiles(x86)%\Google\Chrome\Application\Chrome.exe --incognito "https://accounts.google.com/ServiceLogin?service=mail&passive=true&rm=false&continue=https://mail.google.com/mail/&ss=1&scc=1<mpl=default<mplcache=2&emr=1&osid=1#identifier"
exit
However, when I double-click the .bat
file, a cmd window appears with an error window in front that says:
Windows cannot find 'C:\Program'. Make sure you typed it correctly, and then try again.
I think cmd is evaluating %ProgramFiles(x86)%
without putting quotes around it or something. I'm new to writing bat files, so I'm not sure how to fix this.
Here's some deets about my system:
Windows 10 Pro
V. 1607
OS Build 14393.479
64-bit
Surface Book
Best Answer
Even If you are using the Environment var
usually expands to
Paths having spaces in them have to be enclosed in quotes
Second is that Start uses the first argument in Quotes as title. See
Help Start
This changed batch works as expected: