|
NeoASlan
初级用户
 
积分 41
发帖 16
注册 2006-10-1
状态 离线
|
  『楼 主』:
[半原创]如何在右键新建里添加新建Bat文件
使用 LLM 解释/回答一下
一直以来我一直是一个人独立学习DOS,偶然发现这个论坛,进来一看,激动得热泪盈眶:原来还有这么多志同道合的朋友们。。。
刚来到这里,就学到了很多有用的东西,希望以后能跟大家多多学习。
今天中秋,祝大家中秋节快乐。
时常编写BAT文件,以前总是新建一个文本,然后另存为 .bat,每次都有这个费事的步骤,于是想如何在右键新建菜单里添加新建批处理文件。
搜索发现论坛里没有这样的文章,结合昨天看到的新建CMD文件的文章,借用一下IceCrack在“如何在右键新建菜单里添加新建批处理TEST.CMD文件”帖子里的批处理,( http://www.cn-dos.net/forum/viewthread.php?tid=21417&fpage=1&highlight=%E6%96%B0%E5%BB%BA)
自己进行了一点扩充,修改为在右键新建里,添加 “TestBat”的批处理文件。
这里多实现了新建时的名字默认为“新建 MS-DOS 批处理文件”自定义为“新建 TestBat”,遗憾的是,“新建”二字不知如何去除。
希望这能算得上送给大家的中秋礼物:
@echo off
cd /d %temp%
echo Windows Registry Editor Version 5.00 >>tmp.reg
echo.>>tmp.reg
::下面这个键用来在右键新建里添加“BAT文件”
echo >>tmp.reg
echo "NullFile"="" >>tmp.reg
echo @="" >>tmp.reg
echo.>>tmp.reg
::下面这个键用来自定义新建bat文件的名字,这里设置为“TestBat”
echo >>tmp.reg
echo @="TestBat" >>tmp.reg
echo "EditFlags"=hex:30,04,00,00 >>tmp.reg
regedit /s tmp.reg
del tmp.reg
exit
特此感谢IceCrack,他的批处理做得很好,于是就不想自己再写了,望见谅。
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.
|
|
2006-10-6 22:57 |
|
|
NeoASlan
初级用户
 
积分 41
发帖 16
注册 2006-10-1
状态 离线
|
『第 2 楼』:
使用 LLM 解释/回答一下
把echo @="TestBat" >>tmp.reg 中的TestBat,换成变量%date%,也可以新建出以当前时间命名的批处理文件。刚想到,告诉大家一声。。。
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.
|
|
2006-10-6 23:02 |
|
|
lxmxn
版主
       
积分 11386
发帖 4938
注册 2006-7-23
状态 离线
|
『第 3 楼』:
使用 LLM 解释/回答一下
谢谢你的中秋礼物~
真是相见恨晚啊,以前总是像你所说的那样新建BAT文件,麻烦死了~
今天算是解决了~
同时祝愿你和论坛的所有朋友——中秋节快乐~~
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~~
|
|
2006-10-6 23:54 |
|
|
utem999
初级用户
 
积分 135
发帖 54
注册 2006-9-10
状态 离线
|
|
2006-10-7 01:04 |
|
|
wydos
中级用户
  
积分 304
发帖 117
注册 2006-4-4
状态 离线
|
『第 5 楼』:
使用 LLM 解释/回答一下
谢了,收下了。
%date:~0,-4% 我用这个把星期几给去掉。
但我觉的那个“新建”,挺烦的,不知能不能把它去掉,不出现在文件名中
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
|
|
2006-10-7 03:41 |
|
|
NeoASlan
初级用户
 
积分 41
发帖 16
注册 2006-10-1
状态 离线
|
『第 6 楼』:
使用 LLM 解释/回答一下
To wydos:
%date:~0,-4% 等同于 %date:~0,10%
昨天在论坛里才看到 ~0,4 的用法,今天又知道原来-4就是除掉后四位的写法,非常感谢。
“新建”二字确实烦人,我会记住这个问题并寻求解决方法,希望高手指点。
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.
|
|
2006-10-7 10:54 |
|
|
h2o
初级用户
 
积分 44
发帖 18
注册 2006-10-9
状态 离线
|
『第 7 楼』:
使用 LLM 解释/回答一下
喜欢这个功能
以后也不用新建记事本了
"新建 " 这个,似乎是在这里……( xp sp2 )
system32 目录下的 shell32.dll 文件里的 字符串 的 第 260 个的编号是 4156 的-( 4156,"新建 " )
可以用软件 exescope 或者别的什么来修改 shell32.dll 然后安全模式替换原来的( 不到安全模式也可以 先到 x:\WINDOWS\system32\dllcache 里把 shell32.dll 改名,然后 把 x:\WINDOWS\system32 里正在使用的 shell32.dll 改名 备份,然后 把你修改好的 dll 复制到system32 里边 重启 要是没意外 估计就 ok 了 )
ps:改 "新建 " 这个没改过 不知道是不是这里 不过,改过别的,好像都 ok
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
|
|
2006-10-9 13:48 |
|
|
ljs3509
初级用户
 
积分 28
发帖 14
注册 2006-8-16
状态 离线
|
|
2006-10-9 22:15 |
|
|
zouzhxi
中级用户
   蝴蝶之吻
积分 430
发帖 177
注册 2006-9-20 来自 广东深圳
状态 离线
|
|
2006-10-10 09:30 |
|
|
NeoASlan
初级用户
 
积分 41
发帖 16
注册 2006-10-1
状态 离线
|
『第 10 楼』:
使用 LLM 解释/回答一下
To h2o:
谢谢你的帮助,可惜我现在暂时测试不了,过段时间再弄。。这段时间有点别的事情。来这里都是忙里偷闲来的,呵呵。。。
To zouzhxi:
看你想要什么样的名字,如果就想新建出来的bat文件名字是:“新建 TestBat”,直接用帖子上的那段代码就行。
使用当前日期(含星期几):
要把星期去掉,保留日期,用wydos的代码替换原帖TestBat代码。
要把日期去掉,保留星期,用 %date:~-3,3% 或 %date:~11,3% 替换原帖中TestBat即可。
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%.
|
|
2006-10-10 10:33 |
|
|
NeoASlan
初级用户
 
积分 41
发帖 16
注册 2006-10-1
状态 离线
|
『第 11 楼』:
使用 LLM 解释/回答一下
其实原帖上给出的代码就是给出了自定义名字的方法。
定义的名字可以使用字符串变量也可以使用字符串常量,用echo 能返回什么样的显示,一般就能用什么样的名字。
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.
|
|
2006-10-10 10:35 |
|
|
wydos
中级用户
  
积分 304
发帖 117
注册 2006-4-4
状态 离线
|
『第 12 楼』:
使用 LLM 解释/回答一下
用了几天都不见%date%自动更新,到不如不用这个文件名。
不知各位能不能自动更新日期名?
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?
|
|
2006-10-10 10:55 |
|
|
zh159
金牌会员
     
积分 3687
发帖 1467
注册 2005-8-8
状态 离线
|
『第 13 楼』:
使用 LLM 解释/回答一下
%date%只是每次运行bat注册时才有效(也就是在bat中才有效),%date%直接在注册表中生成当天日期,无法自动修改,除非每天开机自动运行一次该bat
%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
|
|
2006-10-10 22:35 |
|
|
NeoASlan
初级用户
 
积分 41
发帖 16
注册 2006-10-1
状态 离线
|
『第 14 楼』:
使用 LLM 解释/回答一下
那就是说,不管是变量还是常量,都要储存于注册表中,而且是作为常量储存。。
这个倒没有试过,不喜欢用日期,太长了,而且体现不了bat的主题,不人性化。
所以还是用TestBat,编写测试完这个Bat后再改个实际一点的名字为好。
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.
|
|
2006-10-11 00:00 |
|
|
hanbsome
初级用户
 
积分 36
发帖 14
注册 2006-4-29
状态 离线
|
『第 15 楼』:
使用 LLM 解释/回答一下
高手啊。这样强悍的东西要顶才行。
Wow, such a powerful thing deserves a thumbs-up.
|
|
2006-10-11 06:29 |
|