|
2691614
初级用户
 
积分 30
发帖 11
注册 2006-6-11
状态 离线
|
『楼 主』:
请教,BAT文件关联,问题!(多谢electronixtar 已解决)
使用 LLM 解释/回答一下
我想用BAT做文件关联,可是有个小问题,请教高手,帮忙解决!
例如本人想把 .jsb文件,关联成用记事本打开。下面是命令,在DOS命令提示符下可以实现
Assoc .jsb=jsb
Ftype jsb=C:\WINDOWS\system32\notepad.exe %1
但本人想用BAT实现,批处理关联文件,下面是BAT脚本
@ECHO off
cls
color B
ECHO.
ECHO JSB文件关联
ECHO.
pause
Assoc .JSB=JSB
Ftype JSB=C:\WINDOWS\system32\notepad.exe %1
ECHO.
ECHO JSB文件关联成功
ECHO.
pause
exit
问题,本人是用样的命令,在命令提示符下可以实现,在BAT中无法实现。为什么,在命令提示符下,可以给定义1%的变量,在BAT中不能实现1%的变量,不能实现1%的变量,打开后是空的! 请高手告诉我怎么解决,我应该怎么写BAT,我觉得我是书写格式错误。
Last edited by 2691614 on 2006-9-16 at 05:44 ]
I want to use BAT to do file association, but there is a small problem, ask experts to help solve!
For example, I want to associate the .jsb file to be opened with Notepad. The following is the command, which can be realized under the DOS command prompt
Assoc .jsb=jsb
Ftype jsb=C:\WINDOWS\system32\notepad.exe %1
But I want to use BAT to realize batch processing to associate files. The following is the BAT script
@ECHO off
cls
color B
ECHO.
ECHO JSB file association
ECHO.
pause
Assoc .JSB=JSB
Ftype JSB=C:\WINDOWS\system32\notepad.exe %1
ECHO.
ECHO JSB file association succeeded
ECHO.
pause
exit
Problem, I use the same command, which can be realized under the command prompt, but cannot be realized in BAT. Why? Under the command prompt, I can define the variable of 1%, but in BAT, I cannot realize the variable of 1%, and after opening, it is empty! Please tell me how to solve it by experts. How should I write BAT? I think I have a wrong writing format.
Last edited by 2691614 on 2006-9-16 at 05:44 ]
|
|
2006-9-16 01:42 |
|
|
electronixtar
铂金会员
      
积分 7493
发帖 2672
注册 2005-9-2
状态 离线
|
『第 2 楼』:
使用 LLM 解释/回答一下
用 ^%
|

C:\>BLOG http://initiative.yo2.cn/
C:\>hh.exe ntcmds.chm::/ntcmds.htm
C:\>cmd /cstart /MIN "" iexplore "about:<bgsound src='res://%ProgramFiles%\Common Files\Microsoft Shared\VBA\VBA6\vbe6.dll/10/5432'>" |
|
2006-9-16 03:08 |
|
|
2691614
初级用户
 
积分 30
发帖 11
注册 2006-6-11
状态 离线
|
『第 3 楼』:
使用 LLM 解释/回答一下
谢谢你,我这么写的 BAT
@ECHO off
cls
color B
ECHO.
ECHO JSB文件关联
ECHO.
pause
Assoc .JSB=JSB
Ftype JSB=C:\WINDOWS\system32\notepad.exe ^%1
ECHO.
ECHO JSB文件关联成功
ECHO.
pause
exit
可是还是无法控制 1%的变量,在命令提示符下可以定义C:\WINDOWS\system32\notepad.exe %1 在BAT 只是C:\WINDOWS\system32\notepad.exe 没有1%,就无法读取!
麻烦你再帮帮我,谢谢!
Thank you. I wrote the BAT like this:
@ECHO off
cls
color B
ECHO.
ECHO JSB file association
ECHO.
pause
Assoc .JSB=JSB
Ftype JSB=C:\WINDOWS\system32\notepad.exe ^%1
ECHO.
ECHO JSB file association succeeded
ECHO.
pause
exit
But still can't control the 1% variable. In the command prompt, I can define C:\WINDOWS\system32\notepad.exe %1. In the BAT, it's just C:\WINDOWS\system32\notepad.exe without 1%, so it can't read!
Please help me again, thank you!
|
|
2006-9-16 03:47 |
|
|
electronixtar
铂金会员
      
积分 7493
发帖 2672
注册 2005-9-2
状态 离线
|
『第 4 楼』:
使用 LLM 解释/回答一下
哪就两个%%
|

C:\>BLOG http://initiative.yo2.cn/
C:\>hh.exe ntcmds.chm::/ntcmds.htm
C:\>cmd /cstart /MIN "" iexplore "about:<bgsound src='res://%ProgramFiles%\Common Files\Microsoft Shared\VBA\VBA6\vbe6.dll/10/5432'>" |
|
2006-9-16 04:02 |
|
|
2691614
初级用户
 
积分 30
发帖 11
注册 2006-6-11
状态 离线
|
『第 5 楼』:
使用 LLM 解释/回答一下
那个1%,是控制打开函数的,要是没有1%,只是打开一个空的记事本,有了1%,就可以加载文件里面的内容。
在命令提示符下,可以加1%变量,在BAT里就无法加1%的变量。
BAT里C:\WINDOWS\system32\notepad.exe %1的定义为C:\WINDOWS\system32\notepad.exe 后面的%1无法加载。
That 1% is for controlling the open function. If there is no 1%, it just opens an empty Notepad. With 1%, it can load the content in the file.
In the command prompt, you can add the %1 variable, but in BAT, you can't add the %1 variable.
In BAT, the definition of C:\WINDOWS\system32\notepad.exe %1 is that the %1 after C:\WINDOWS\system32\notepad.exe cannot be loaded.
附件
1: Image00000.jpg (2006-9-16 04:05, 80.12 KiB, 下载附件所需积分 1 点
,下载次数: 1)
|
|
2006-9-16 04:05 |
|
|
2691614
初级用户
 
积分 30
发帖 11
注册 2006-6-11
状态 离线
|
『第 6 楼』:
使用 LLM 解释/回答一下
OK 谢谢了,两个%%号就可以了!!!
哈哈,谢谢你! 我是菜鸟,长知识了!
OK, thank you. Just two % signs are enough!!!
Haha, thank you! I'm a novice, learned something new!
|
|
2006-9-16 04:06 |
|
|
2691614
初级用户
 
积分 30
发帖 11
注册 2006-6-11
状态 离线
|
『第 7 楼』:
使用 LLM 解释/回答一下
还有个问题,想问一下,系统盘的Windows或WIN可以用%SystemRoot%来定义
那么系统的Program Files 用什么定义呢! 谢谢了!
There is another question. I want to ask, the Windows or WIN of the system disk can be defined with %SystemRoot%. Then what is used to define the system's Program Files! Thanks.
|
|
2006-9-16 04:12 |
|
|
2691614
初级用户
 
积分 30
发帖 11
注册 2006-6-11
状态 离线
|
|
2006-9-16 04:52 |
|
|
electronixtar
铂金会员
      
积分 7493
发帖 2672
注册 2005-9-2
状态 离线
|
『第 9 楼』:
使用 LLM 解释/回答一下
回复7楼:
自己运行 set 看看吧
得到答案:
%ProgramFiles%
就可以了
Reply to floor 7:
Just run set yourself and see.
The answer is:
%ProgramFiles%
|

C:\>BLOG http://initiative.yo2.cn/
C:\>hh.exe ntcmds.chm::/ntcmds.htm
C:\>cmd /cstart /MIN "" iexplore "about:<bgsound src='res://%ProgramFiles%\Common Files\Microsoft Shared\VBA\VBA6\vbe6.dll/10/5432'>" |
|
2006-9-16 08:52 |
|