2

I want to create a shortcut that launches chrome with an HTML file in the same directory as the shortcut. I also need it to launch chrome with the following parameters --new-window --disable-web-security --user-data-dir="c:/chromedev"

Currently the "Target" line of my shortcut looks like this:

"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" ./specViewer.html --new-window --disable-web-security --user-data-dir="c:/chromedev"

Launching this gives me the ERR_NAME_NOT_RESOLVED error

I've also tried this:

"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" specViewer.html --new-window --disable-web-security --user-data-dir="c:/chromedev"

With no such luck, as then it tries to search the internet for my file.

Any ideas on a solution to properly launch the local file in chrome with the command line parameters?

4

The OP's answer is correct as far as it goes. However, you can get a Windows shortcut to launch relative to the current directory.

While you can use Windows Environment Variables in shortcuts, there are a few volatile ones that cannot be used (such as %CD%).

As the OP suggested, using a batch file is an excellent way to bypass this restriction:

@echo off
start "" "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" "file:///%CD%/specViewer.html" --user-data-dir="C:/chromedev" --disable-web-security --new-window

You can also create a New Shortcut with the following properties:

Target:      "%WINDIR%\system32\cmd.exe" /c start "" "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" "file:///%CD%/specViewer.html" --user-data-dir="C:/chromedev" --disable-web-security --new-window
Start in:    
Change Icon: "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"

CRITICAL: make sure Start in is empty; this will start command prompt in the current directory.

Notice how we launched command prompt, which can use dynamic variables such as %CD%. And you'll probably want to change the icon on the shortcut to look like Google Chrome, or whatever program you are launching.


For more on the peripheral details, see this question:

Making a Windows shortcut start relative to where the folder is? - Stack Overflow

  • 1
    I like you're answer. I've already distributed my html file with the batch script. If I ever need to do this again, I will have try this out! I am marking yours as accepted since it mentioned my answer also – Oxymoron Jul 21 '17 at 19:30
3

I was able to solve my problem by instead using a .bat file and using this as it's content

"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" "file:///%cd%/specViewer.html" --user-data-dir="C:/chromedev" --disable-web-security --new-window 

Note: prefixing that command is START breaks it.

  • 1
    Using START or CALL is not always necessary, but prefixing the above command with START "title" will fix it again. You need the "title" argument, even if it is just a pair of empty quotes. See also: ss64.com/nt/start.html – JonathanDavidArndt Jul 20 '17 at 17:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.