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

  • Members
  • PipPipPipPip
  • 596 posts
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
  • 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.

#3
prathapml

prathapml

    Follow the rules please :-)

  • Patrons
  • 6,791 posts
  • 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"

#4
Sunil

Sunil

    Senior Member

  • Members
  • PipPipPipPip
  • 596 posts
@ 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

  • Members
  • PipPipPipPip
  • 596 posts
Guys need some help on this, doesnt anyone know of such code

#6
Sunil

Sunil

    Senior Member

  • Members
  • PipPipPipPip
  • 596 posts
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

  • Members
  • 17 posts
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

  • Members
  • PipPip
  • 152 posts
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.




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users



How to remove advertisement from MSFN