Jump to content

Welcome to MSFN Forum
Register now to gain access to all of our features. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more. This message will be removed once you have signed in.
Login to Account Create an Account



Photo

Put the current directory into a batch file

- - - - -

  • Please log in to reply
7 replies to this topic

#1
Sunil

Sunil

    Senior Member

  • Member
  • PipPipPipPip
  • 596 posts
  • Joined 24-June 03
Hey, im trying to make a batch file, i want it to work like how the open command window here windows power toy works, when i right click on a directory it automatically gets the directory name and path, is there anyway to accomplish this.


How to remove advertisement from MSFN

#2
prathapml

prathapml

    Follow the rules please :-)

  • Patrons
  • 6,791 posts
  • Joined 14-November 03
  • OS:Windows 8 x64
  • Country: Country Flag
A registry tweak for that:
Windows Registry Editor Version 5.00

; These tweaks apply for all users
; Get a new Right-click menu option
[HKEY_CLASSES_ROOT\Directory\shell\Command Prompt Here]
@="Command &Prompt Here"
[HKEY_CLASSES_ROOT\Directory\shell\Command Prompt Here\command]
@="cmd.exe /k cd %1 "

Save it exactly as it is in a any-name.reg file and double-click it to apply.
Posted ImageCheers !!!   Donate to MSFN and Help Keep This Site Running
||Please Read the Forum Rules||  Etiquette   || Welcome to MSFN - Forum Basics || Before posting
prathapml :: MSFN Supermod :: Private Message me if you ever have a problem while at MSFN

#3
prathapml

prathapml

    Follow the rules please :-)

  • Patrons
  • 6,791 posts
  • Joined 14-November 03
  • OS:Windows 8 x64
  • Country: Country Flag
or do you need a variable that can be used in a batch file ?
(you may already know this one)
If I was running this file from "M:\SETUP\PRO3\$OEM$\$1\install\base"
then "M:\SETUP\PRO3\$OEM$\$1\install\base\myapp.exe /S"
would be better written as "%CD%\myapp.exe /S"
Posted ImageCheers !!!   Donate to MSFN and Help Keep This Site Running
||Please Read the Forum Rules||  Etiquette   || Welcome to MSFN - Forum Basics || Before posting
prathapml :: MSFN Supermod :: Private Message me if you ever have a problem while at MSFN

#4
Sunil

Sunil

    Senior Member

  • Member
  • PipPipPipPip
  • 596 posts
  • Joined 24-June 03
@ prathapml

The code must put the highlighted directory name and path into the bach file, not the way you outlined.

ps thanks for trying

#5
Sunil

Sunil

    Senior Member

  • Member
  • PipPipPipPip
  • 596 posts
  • Joined 24-June 03
Guys need some help on this, doesnt anyone know of such code

#6
Sunil

Sunil

    Senior Member

  • Member
  • PipPipPipPip
  • 596 posts
  • Joined 24-June 03
i was able to find this little bit of code, but it only works for the directory you are in, not highlighted

:: curdir.bat
@SET cd=
@SET promp$=%prompt%
@PROMPT SET cd$Q$P
@CALL>%temp%.\setdir.bat
@
% do not delete this line %
PROMPT %promp$%
FOR %%c IN (CALL DEL) DO %%c %temp%.\setdir.bat

anyone out there knows how to modify it so i can get the name of the highlighted directory?

#7
Fuzzy Viking

Fuzzy Viking

    Newbie

  • Member
  • 17 posts
  • Joined 26-February 04
If I understand you correctly, you wish to rightclick a directory and from the menu run a batchfile, which gets the full path in as a parameter ?

Then you have already got what you need from prathapml :

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Directory\shell\Batch]
@="My Batch Thingy"

[HKEY_CLASSES_ROOT\Directory\shell\Batch\Command]
@="c:\\my.bat \"%1\""


then in the batch file :

@echo off

echo Received folder as parameter : %1

pause

#8
RayOK

RayOK

    Member

  • Member
  • PipPip
  • 152 posts
  • Joined 21-September 03
You may have already found something but this might work. Sets a variable to the current directory.

Set Folder=%cd%

That would set the variable folder to whatever directory the batch file is in at that moment. Type set /? for more info. Works in XP, not sure about anything else.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users