Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8119197
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T04:44:01+00:00 2026-06-06T04:44:01+00:00

myprogram.cmd is in PATH; myprogram.cmd uses %~dp0 to determine the folder it is in;

  • 0

myprogram.cmd is in PATH;

myprogram.cmd uses %~dp0 to determine the folder it is in;

I have included @echo %~dp0 into myprogram.cmd for debugging;

When I call myprogram.cmd from anywhere, it works perfectly, displaying the folder myprogram.cmd is in;

When I call hg extdiff -p myprogram.cmd, it does not work, displaying something like c:\Users\Username\AppData\Local\Temp\extdiff.3n8op2\.

Here is the related part of hgrc file:

[extensions]
hgext.extdiff = 

What do I do wrong? Should not %~dp0 return drive and path of the batch file? What do I use instead? Do I have to apply some special configuration to Mercurial repository? Passing the full path of myprogram.cmd to hg extdiff -p is not an option, unless it is done automatically.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T04:44:03+00:00Added an answer on June 6, 2026 at 4:44 am

    You can try using %~dp$PATH:0, but you need to always specify the extension. For example, for the following test.cmd:

    rem test.cmd
    @echo dp0 == %~dp0
    @echo dp$PATH:0 == %~dp$PATH:0
    

    these are two sample runs from the d:\hg folder:

    $ hg extdiff -p test.cmd
    dp0 == c:\Users\estefan\AppData\Local\Temp\extdiff.pamj6n\
    dp$PATH:0 == k:\home\Scripts\
    
    $ hg extdiff -p test
    dp0 == c:\Users\estefan\AppData\Local\Temp\extdiff.dgp0qz\
    dp$PATH:0 ==
    

    From http://ss64.com/nt/syntax-args.html:

    %~$PATH:1 Search the PATH environment variable and expand %1 to the fully qualified name of the first match found.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wanted to run a .cmd file from Java. I have something which works
I have inserted a lot of information into a SQlite database from my program.
I have a C executable (named myprogram). When I run it by ./myprogram I
I'm using Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + \MyProgram As the path to store several files used by
I have a class with like 50 methods. class MyProgram(object): def method1(self): pass def
My image is passed into my program from a server and saved as a
I have a program that accepts a Cmd command as a command argument. Basically
As soon as I open the VS cmd prompt it says ERROR: Cannot determine
I created a C#.net app that uses dates from a SQL Server 2008 database
I am running into this problem. my program invokes Runtime.getRuntime().exec(cmd); on a windows platform.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.