Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
share|improve this question
up vote 3 down vote accepted

%~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
share|improve this answer
    
Thanks! I added the path delimiter to your answer. – Mr. Polywhirl Jan 24 '13 at 4:43
1  
So I see. I was testing from C:\ , and when that is the working directory, %cd% includes the trailing \ . – William Jackson Jan 24 '13 at 4:45

You must log in to answer this question.

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