1

Hello I have the following batch file saved to a location called C:\.alias. I added this directory to the path so that I can run all my custom scripts. I have tried creating a script to open a file in Chrome. When I am in another directory e.g. C:\code\python I call my script: chrome.cmd text.svg but Chrome tries to open: file:///C:/.alias/test.svg. Is there a way to prepend current path to the filename argument? Thanks.

chrome.cmd

@echo off
"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" %~dp0%1

1 Answer 1

3

%~dp0 is the path to the location of the batch file.

%cd% is the current working directory.

This is what you need:

@echo off
"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" %cd%\%1
1
  • 1
    So I see. I was testing from C:\ , and when that is the working directory, %cd% includes the trailing \ . Jan 24, 2013 at 4:45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .