中国DOS联盟论坛

China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --
Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
Guest | Log in | Register | Members | Search | China DOS Union
中国DOS联盟论坛
The time now is 2026-09-15 12:59
47,812 topics / 349,917 posts / today 0 new / 48,268 members
DOS批处理 & 脚本技术(批处理室) » [Semi-original] How to add a new Bat file in the right-click new
Printable Version  6,823 / 29
Floor1 NeoASlan Posted 2006-10-06 22:57
初级用户 Posts 16 Credits 41
I have been learning DOS independently all the time. Accidentally discovered this forum. When I came in, I was so excited that I almost burst into tears: there are still so many like-minded friends...
Just came here and learned a lot of useful things. Hope to learn more from you all in the future.
Today is Mid-Autumn Festival. Wish you all a happy Mid-Autumn Festival.

I often write BAT files. I always create a new text before and save it as.bat. There is always this cumbersome step. So I want to add the new batch file in the right-click new menu.
Searched and found no such article in the forum. Combined with the article of creating CMD I saw yesterday, borrowed the batch of IceCrack in the post "How to add new batch TEST.CMD file in the right-click new menu", (url)http://www.cn-dos.net/forum/viewthread.php?tid=21417&fpage=1&highlight=%E6%96%B0%E5%BB%BA)
Did a little expansion by myself, modified to add "TestBat" batch file in the right-click new.
Here, the name when creating is defaulted to "New MS-DOS batch file" customized to "New TestBat". Unfortunately, I don't know how to remove the word "New".
Hope this can be regarded as a Mid-Autumn gift for you all:

@echo off
cd /d %temp%
echo Windows Registry Editor Version 5.00 >>tmp.reg
echo.>>tmp.reg
:: The following key is used to add "BAT file" in the right-click new
echo >>tmp.reg
echo "NullFile"="" >>tmp.reg
echo @="" >>tmp.reg
echo.>>tmp.reg
:: The following key is used to customize the name of the new bat file, set to "TestBat" here
echo >>tmp.reg
echo @="TestBat" >>tmp.reg
echo "EditFlags"=hex:30,04,00,00 >>tmp.reg
regedit /s tmp.reg
del tmp.reg
exit

Special thanks to IceCrack, his batch is very good, so I don't want to write it myself, forgive me.
Floor2 NeoASlan Posted 2006-10-06 23:02
初级用户 Posts 16 Credits 41
Just now I thought of it, so I'll let you all know. Change "TestBat" in "echo @="TestBat" >>tmp.reg" to the variable %date%, and you can also create a batch file named with the current time.
Floor3 lxmxn Posted 2006-10-06 23:54
版主 Posts 4,938 Credits 11,386

Thank you for your Mid-Autumn Festival gift~
It's really a case of better late than never. I used to create BAT files as you said before, which was so troublesome~
Today it's finally solved~
At the same time, I wish you and all the friends in the forum a happy Mid-Autumn Festival~~
Floor4 utem999 Posted 2006-10-07 01:04
初级用户 Posts 54 Credits 135
Thanks
Very good indeed
Floor5 wydos Posted 2006-10-07 03:41
中级用户 Posts 117 Credits 304
Thanks, I'll take it.
%date:~0,-4% I use this to remove the day of the week.
But I feel that "New" is quite annoying. I wonder if I can remove it and not have it appear in the file name
Floor6 NeoASlan Posted 2006-10-07 10:54
初级用户 Posts 16 Credits 41
To wydos:
%date:~0,-4% is equivalent to %date:~0,10%
I just saw the usage of ~0,4 in the forum yesterday, and today I learned that -4 means removing the last four digits. Thanks a lot.

The word "New" is really annoying. I will remember this problem and look for a solution. I hope experts can give guidance.
Floor7 h2o Posted 2006-10-09 13:48
初级用户 Posts 18 Credits 44
Like this function
No need to create a new notepad in the future

The "New" seems to be here... (xp sp2)
The string in the shell32.dll file in the system32 directory, the number of the 260th one is 4156 - (4156, "New")

You can use the software exescope or something else to modify shell32.dll, then replace the original in safe mode (you don't need to go to safe mode first, go to x:\WINDOWS\system32\dllcache to rename shell32.dll, then rename the shell32.dll in use in x:\WINDOWS\system32 for backup, then copy your modified dll to system32, restart, if there are no accidents, it should be okay)

ps: I haven't modified "New" before, I don't know if it's here, but I modified others, it seems okay
Floor8 ljs3509 Posted 2006-10-09 22:15
初级用户 Posts 14 Credits 28
Floor9 zouzhxi Posted 2006-10-10 09:30
中级用户 Posts 177 Credits 430 From 广东深圳
TO wydos:
If I want to remove the date.???
How to do it...
Floor10 NeoASlan Posted 2006-10-10 10:33
初级用户 Posts 16 Credits 41
To h2o:
Thank you for your help. Unfortunately, I can't test it for now. I'll do it later. There are some other things going on these days. I come here just to take a break from being busy, hehe...

To zouzhxi:
It depends on what kind of name you want. If you just want the newly created bat file to be named "New TestBat", just use the code in the post.
Using the current date (including the day of the week):
To remove the day of the week and keep the date, replace the original TestBat code with wydos's code.
To remove the date and keep the day of the week, replace TestBat in the original post with %date:~-3,3% or %date:~11,3%.
Floor11 NeoASlan Posted 2006-10-10 10:35
初级用户 Posts 16 Credits 41
In fact, the code given in the original post shows the method of customizing the name. The defined name can use string variables or string constants. What kind of display can be returned with echo, and generally, the corresponding name can be used.
Floor12 wydos Posted 2006-10-10 10:55
中级用户 Posts 117 Credits 304
After using it for a few days, the %date% didn't update automatically. It's better not to use this file name. I wonder if you all can automatically update the date - named one?
Floor13 zh159 Posted 2006-10-10 22:35
金牌会员 Posts 1,467 Credits 3,687
%date% is only effective when the bat is run for registration each time (that is, only effective in the bat). %date% directly generates the current day's date in the registry and cannot be modified automatically unless this bat is run automatically every day when the computer starts
Floor14 NeoASlan Posted 2006-10-11 00:00
初级用户 Posts 16 Credits 41
That is to say, whether it is a variable or a constant, it should be stored in the registry and stored as a constant.

This has not been tried yet. I don't like using dates because they are too long and don't reflect the theme of the bat, which is not user-friendly.

So it is better to use TestBat, write and test this Bat, and then change it to a more practical name.
Floor15 hanbsome Posted 2006-10-11 06:29
初级用户 Posts 14 Credits 36
Wow, such a powerful thing deserves a thumbs-up.
1 2  Next
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023