China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-07-31 23:34
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » How to create a new batch file? View 1,429 Replies 13
Original Poster Posted 2007-02-25 02:27 ·  中国 四川 绵阳 江油市 电信
高级用户
★★★
Credits 502
Posts 327
Joined 2006-12-30 06:01
19-year member
UID 74981
Gender Male
Status Offline
Been lurking for a long time, post a new thread to ask

Everyone, what do you use to create a new batch file?

For example: right-click
@echo off
reg add HKCR\.bat\ShellNew /v nullfile /f
reg add HKCR\batfile /v e /d p /f

I counted, need right-click (new p) - left-click (click) - rename (keyboard) - right-click (edit) - left-click (click)

Oh my god, have to click the mouse 4 times, and also right-left-right-left, it's very troublesome, and then have to (@echo off) -- have to type 8 characters on the keyboard, a space,

Is there a faster way, preferably double-click to be okay?

[ Last edited by qingfushuan on 2007-2-24 at 01:29 PM ]
Floor 2 Posted 2007-02-25 02:47 ·  中国 广东 湛江 电信
高级用户
★★★
Credits 959
Posts 311
Joined 2006-04-11 14:08
20-year member
UID 53665
Gender Male
From 广东-LianJiang
Status Offline
I was a bit stunned when I saw the thread started by the LZ.
How come the LZ is also a medium-level user, why still post such a thread...
It's not strange if a newbie asks, but speechless...
κχυμγνξοθπρωψιαδλεηφβτζσ┬╀┾┳┞┯┰┱┣┲┳╂╁│├┟┭┠这是什么??这就是我的人生
Floor 3 Posted 2007-02-25 02:52 ·  中国 四川 绵阳 江油市 电信
高级用户
★★★
Credits 502
Posts 327
Joined 2006-12-30 06:01
19-year member
UID 74981
Gender Male
Status Offline
Spent 2 hours to the water area and got 300 points, heh
Floor 4 Posted 2007-02-25 03:19 ·  中国 广东 广州 天河区 电信
金牌会员
★★★★
一叶枝头,万树皆春
Credits 2,564
Posts 1,127
Joined 2006-12-25 22:57
19-year member
UID 74552
Gender Male
Status Offline
```
SET TL="%userprofile%\Templates\sscript.cmd"
ECHO @ECHO OFF>%TL%
ECHO ::SETLOCAL ENABLEDELAYEDEXPANSION>>%TL%
ECHO.>>%TL%
ECHO EXIT>>%TL%
REG ADD "HKEY_CLASSES_ROOT\.cmd\shellnew" /v filename /d sscript.cmd /f
```
Recent Ratings for This Post ( 1 in total) Click for details
RaterScoreTime
slore +4 2007-02-25 04:13
Floor 5 Posted 2007-02-25 04:08 ·  中国 陕西 西安 电信
铂金会员
★★★★
Credits 5,212
Posts 2,478
Joined 2007-02-08 23:39
19-year member
UID 79003
Gender Male
Status Offline
Oh, dizzy~ When you right-click to create a new one, it automatically comes out without having to click the left button.

Then here you go~ Just wrote this.

Extract to any folder (haven't tested if there are spaces~ I just put it on drive D).

2 files:

Crbat.cmd:

@echo off
ren %1 "%~n1.bat"
echo @echo off>"%~dpn1.bat"
start NOTEPAD.EXE "%~dpn1.bat"


Register Crbat.bat:

reg add HKCR\.Crbat\ShellNew /v NullFile /f
reg add HKCR\Crbatfile /ve /d Creat" Bat" /f
reg add HKCR\Crbatfile\DefaultIcon /ve /d %windir%\system32\cmd.exe,0 /f
reg add HKCR\Crbatfile\shell /ve /d open /f
reg add HKCR\Crbatfile\shell\open\command /ve /d %cd%\Crbat.cmd" \"%%1\"" /f
assoc.Crbat=Crbatfile


First run the register Crbat.bat, you refresh the new twice, and you can see a Creat Bat file type, you create a new one, then double-click it.
Attachments
4bat.rar (457 bytes, Credits to download 1 pts, Downloads: 7)
Floor 6 Posted 2007-02-25 04:13 ·  中国 陕西 西安 电信
铂金会员
★★★★
Credits 5,212
Posts 2,478
Joined 2007-02-08 23:39
19-year member
UID 79003
Gender Male
Status Offline
The one on the 4th floor is good! Forgot the filename.
Floor 7 Posted 2007-02-25 06:34 ·  中国 四川 绵阳 江油市 电信
高级用户
★★★
Credits 502
Posts 327
Joined 2006-12-30 06:01
19-year member
UID 74981
Gender Male
Status Offline
When I came to the union, I always used it. Create a new text file - rename it to XXX.bat - edit - @echo off, it's so troublesome.

Fortunately, I found the.bat in the right - click. The fifth sentence in the registration of.bat by the friend on the fifth floor is wrong:

reg add HKCR\Crbatfile\shell\open\command /ve /d %cd%\Crbat.cmd" \"%%1\"" /f

Error: too many command - line arguments

Crbat.cmd is okay. Can it be lazier? Can the cursor blink on the second line
Floor 8 Posted 2007-02-25 06:46 ·  中国 广东 广州 天河区 电信
金牌会员
★★★★
一叶枝头,万树皆春
Credits 2,564
Posts 1,127
Joined 2006-12-25 22:57
19-year member
UID 74552
Gender Male
Status Offline
I've always been using the method you've been using. This newly created script is based on imitating the MS-HTML document creation method as you requested
Floor 9 Posted 2007-02-25 06:49 ·  中国 陕西 西安 电信
铂金会员
★★★★
Credits 5,212
Posts 2,478
Joined 2007-02-08 23:39
19-year member
UID 79003
Gender Male
Status Offline
D:\4bat>reg add HKCR\.Crbat\ShellNew /v NullFile /f

The operation completed successfully.

D:\4bat>reg add HKCR\Crbatfile /ve /d Creat" Bat" /f

The operation completed successfully.

D:\4bat>reg add HKCR\Crbatfile\DefaultIcon /ve /d C:\WINDOWS\system32\cmd.exe,0
/f

The operation completed successfully.

D:\4bat>reg add HKCR\Crbatfile\shell /ve /d open /f

The operation completed successfully.

D:\4bat>reg add HKCR\Crbatfile\shell\open\command /ve /d D:\4bat\Crbat.cmd" \"%
1\"" /f

The operation completed successfully.

You have a space in the path...
Floor 10 Posted 2007-02-25 21:50 ·  中国 广东 广州 天河区 电信
中级用户
★★
Credits 326
Posts 148
Joined 2005-12-16 12:30
20-year member
UID 47260
Gender Male
Status Offline
Floor 11 Posted 2007-02-26 00:54 ·  中国 四川 绵阳 江油市 电信
高级用户
★★★
Credits 502
Posts 327
Joined 2006-12-30 06:01
19-year member
UID 74981
Gender Male
Status Offline
Crbat.cmd is okay. Can you be lazier? Can the cursor flash on the second line so that I don't have to press the ↓ key again
Floor 12 Posted 2007-02-26 02:58 ·  中国 陕西 西安 电信
铂金会员
★★★★
Credits 5,212
Posts 2,478
Joined 2007-02-08 23:39
19-year member
UID 79003
Gender Male
Status Offline
Then either don't use P, use a script. After opening, send a key press =. = Are you too lazy?
Floor 13 Posted 2007-02-26 05:50 ·  中国 四川 绵阳 江油市 电信
高级用户
★★★
Credits 502
Posts 327
Joined 2006-12-30 06:01
19-year member
UID 74981
Gender Male
Status Offline
Batch processing was originally invented to reduce workload = for the lazy
Floor 14 Posted 2007-03-14 01:43 ·  中国 湖北 潜江 电信
高级用户
★★★
Credits 894
Posts 411
Joined 2007-02-17 12:15
19-year member
UID 79697
Gender Male
Status Offline
You can also use the copy command

copy nul file.bat
@set c= 不知则觉多,知则觉少,越知越多,便觉越来越少. --- 知多少.
@for,/l,%%i,in,(1,1,55)do,@call,set/p=%%c:~%%i,1%%<nul&ping/n 1 127.1>nul


Forum Jump: