-1

I have a batch file named CreateFolders.bat

The code is:

@echo off
md db in links output

Must I copy the batch file to the specific folder before I can run it? Is there anyway possible to have the options to run that specific batch file by a shotcut key or a menu option when you click the right mouse key?

I am dreaming or is it possible?

DavidPostill
  • 153,128
  • 77
  • 353
  • 394
Heresh
  • 103
  • 2
  • If you click the right hand mouse button and it runs the batch file, then what folder or folders are you wanting the batch file to operate in. Also this should be two questions, the first of which is how can you trigger a batch file to operate when you right click. – barlop Sep 23 '16 at 09:17
  • I would want it to run it on the current folder that i am clicking on. – Heresh Sep 23 '16 at 11:45
  • your question is a bit flawed the way it's written.. I don't know the answer but I can help you state the question. Do you want it to run immediately on right click, or selecting with a menu. Perhaps you could ask A)How do you get a batch file to execute when you right click a folder B)How do you get add an item to the right click context menu, so when you right click a folder you can choose to run a program / batch file passing the path of the folder as a parameter to the program.. – barlop Sep 23 '16 at 12:26
  • this may help http://superuser.com/questions/444726/windows-how-to-add-batch-script-action-to-right-click-menu – barlop Sep 23 '16 at 12:28

1 Answers1

0

Have a look to autohotkey it's very flexible. You got to use a bit of scripting but it is not that hard.

edit: To further add more detail to the answer:

First thing, you need to receive the path using arguments in your bat

@echo off
md %1/mydir

I altered this code I found here Autohotkey Filepath so you can execute a .bat in the exact path you want. The following code use the clipboard to copy the path you are currently in.

F1::
MsgBox, % gst()  ; Path
F8::
Run C:\MyBat.bat % gst() ; Execute your bat receiving the path
return
F7::
Run C:\MyBat.bat,,Hide ; Execute your bat without seeing the black window
return

; GetSelectedText or FilePath in Windows Explorer  by Learning one 
gst()
{   
        IsClipEmpty := (Clipboard = "") ? 1 : 0
        if !IsClipEmpty 
        {
                ClipboardBackup := ClipboardAll
                While !(Clipboard = "") 
                {
                      Clipboard = 
                      Sleep, 10
                }
        }
        Send, ^c
        ClipWait, 0.1
        ToReturn := Clipboard, Clipboard := ClipboardBackup
        if !IsClipEmpty
        ClipWait, 0.5, 1
        Return ToReturn
}

where F1, F7, F8 are the keys you need to press to be able to run your program

Joe
  • 663
  • 5
  • 10