473,320 Members | 1,910 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Need help with cmd.exe coding

I have already edited the registry to open a comand prompt here. My question is can the cmd prompt be set to run a command from the registry? I would like to be able to right click in windows explorer and have a selection that would make the cmd prompt execute a command in the current directory. In a nut shell I would like to right click the windows 7 explorer window and click an item in that menu that would make a new sub directory in the current directory. Can this be done. I am not a programmer and don't have much knowledge except in writing easy batch files. Any help would be appreciated as I have been trying to figure this out for two years now. Thanks in advance. Joe
Apr 9 '12 #1

✓ answered by Rabbit

If you pass %1% into the bat. For example, by calling this from the command key in the registry:
Expand|Select|Wrap|Line Numbers
  1. C:\test.bat %1%
Then that passes the path into the bat. Then in the bat I can do this:
Expand|Select|Wrap|Line Numbers
  1. mkdir "%1%\New Directory"
That will create a new directory in the patch passed into the bat.

13 2540
Rabbit
12,516 Expert Mod 8TB
That functionality is already built in. You can right click > New > Folder and that will do the same thing you're trying to do.
Apr 9 '12 #2
Evidently I did not ask the question correctly or you did not understand what I am trying to accomplish. I know you can create a new folder by using what is built into windows but you have to type the name of the folder and if you need to create several folders it is time consuming. If I had several choices in the context menu that would create a sub-folder, one named 1024x768 and another one named 800x600 and all I had to do was just click that selection in the context menu and it would create a subfolder it would save me a lot of time. Thanks.
Apr 10 '12 #3
Rabbit
12,516 Expert Mod 8TB
If you add a subkey to the registry at \HKEY_CLASSES_ROOT\Folder\shell\ and then add a subkey under that called command. You can set the command's default value to call a batch file or script. That way, when you right click a folder, you can call that command from the context menu.
Apr 10 '12 #4
How would you code the batch file to work in the current directory? I know how to write simple batch files and could write one that would create a new directory but I don't know how to write the code that would make it work in the current directory. Thanks for your help.
Apr 10 '12 #5
Rabbit
12,516 Expert Mod 8TB
If you pass %1% into the bat, that variable will contain the path that it was called from.
Apr 10 '12 #6
Rabbit, your way over my head. I know what a variable is but I do not understand pass %1%. If could you write me a simple batch that would create a new sub-directory in the current directory and have it name the new sub directory xxx i would be able to figure out how to change the name of the new directory. I could then create a batch file for each different size of the resized pictures. I think I know how to add them to the context menu. If I thought I could figure it out I wouldn't ask but it is above my ability. If you don't have the time I will understand and thanks for trying to help me with this quest.Joe
Apr 11 '12 #7
Rabbit
12,516 Expert Mod 8TB
If you pass %1% into the bat. For example, by calling this from the command key in the registry:
Expand|Select|Wrap|Line Numbers
  1. C:\test.bat %1%
Then that passes the path into the bat. Then in the bat I can do this:
Expand|Select|Wrap|Line Numbers
  1. mkdir "%1%\New Directory"
That will create a new directory in the patch passed into the bat.
Apr 11 '12 #8
Rabbit, I tried but had no luck. Here is exactly what I did. I created a batch file named test.bat and placed it in the root directory (C). The batch file contained this one line: mkdir "%1%\1024" .
I then opened regedit and went to HKEY_CLASSES_ROOT\Directory\Background\shell and created a new key called 1024 . I then created a new key under 1024 and named it command.
I then entered this into that key: C:\test.bat %1% . The context menu shows a selection called 1024 but when I click on it I get this message: This file does not have a program associated with it for performing this action. Please install a program or, if one is already installed, create an association in the default Programs control panel.
I ran just the batch file from the root directory and it created a new sub folder under c called 1024 so the batch file works. I must not be putting the keys in the correct place in the registry or I have left something out but I don't know what it is.
I must not be doing something right but I don't know what it is. Thanks again Rabbit. Joe
Apr 12 '12 #9
Rabbit
12,516 Expert Mod 8TB
I'm not sure what you mean by you put it into that key but it needs to go into the default value in the command key.
Apr 12 '12 #10
I created a batch file named test.bat with one line of code which is:
mkdir "%1%\1024"
I placed the file test.bat into the root directory (C)
I created a new key in:
HKEY_CLASSES_ROOT\Directory\Background\shell
and named it 1024.
I then created a new sub-key under 1024 and named it command.
I then entered this into the default value of command:
C:\test.bat %1%
The context menu shows 1024 but when I click on it I get the message:
This file does not have a program associated with it for performing this action. Please install a program or, if one is already installed, create an association in the default Programs control panel.
I hope this clears up what I have done. Sometimes I don't phrase things correctly as I don't know all the correct terminology.
Thanks Rabbit for being so patient with me. I do appreciate your trying to help.
Apr 12 '12 #11
Rabbit
12,516 Expert Mod 8TB
That should work. It works for me. But perhaps your .bat association is broken, I would check that.
Apr 12 '12 #12
You were right, Rabbit. When I reset the bat file association it started working. Thank you so much for all your help. It is people like you that give me hope that the internet will not become completely commercialized and people will continue to help others, not always for compensation but just for the sake of exchanging ideas and knowledge.
Apr 12 '12 #13
Rabbit
12,516 Expert Mod 8TB
Not a problem, good luck.
Apr 12 '12 #14

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Larry | last post by:
Help Please http://www.angelfire.com/folk/ps197_brooklyn_ny I currently have a main page that has a list of about 50 names. I then have 50 pages that are linked to the main page The...
3
by: Charleees | last post by:
Hi all, I need C# code for Implementing MD5 Algorithm.. Hope all would have heard of MD5 Algorith... Does any one have the C# coding for that Algorithm.. please Send... ITs URgent..... Thanks...
1
by: Charles | last post by:
Hi all, I need C# code for Implementing MD5 Algorithm.. Hope all would have heard of MD5 Algorith... Does any one have the C# coding for that Algorithm.. please Send... ITs URgent..... Thanks...
1
by: Charles | last post by:
Hi all, I need C# code for Implementing MD5 Algorithm.. Hope all would have heard of MD5 Algorith... Does any one have the C# coding for that Algorithm.. please Send... ITs URgent..... Thanks...
2
by: XML Beginner | last post by:
I have an XML file that contains values that my application needs, so it knows which database to connect to. It also contains a configuration option so that I can specify which node to return...
1
by: flavourofbru | last post by:
Hi, I am stuck at a major part of the code in VC++. My algorithm is as follows: f_name = load(filename); //this also loads a text file. The text files contains numbers sepearted by tab....
2
by: rlemusic | last post by:
Hi everybody, I’m creating a database in Access (I believe it’s 2000) to catalogue items in the archives of a small museum. I’m a total n00b as far as using Access goes, but by looking at some...
2
by: reddysankar | last post by:
Hi to All, iam developing one application.in that i need some coding regarding login time n date of a user for a particular day and logout details of that same user. ...
0
by: srgrector | last post by:
Help? with Coding database modification script using a webform & frames... I will have an Amazon book database that is updated regularly, say weekly. I need a program/script that I can run in...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.