![]() |
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-08-02 03:36 |
48,037 topics / 350,122 posts / today 2 new / 48,250 members |
| DOS批处理 & 脚本技术(批处理室) » Ask about BAT file association, problem! (Thanks to electronixtar for solving it) |
| Printable Version 1,551 / 8 |
| Floor1 2691614 | Posted 2006-09-16 01:42 |
| 初级用户 Posts 11 Credits 30 | |
|
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 ] |
|
| Floor2 electronixtar | Posted 2006-09-16 03:08 |
| 铂金会员 Posts 2,672 Credits 7,493 | |
| Floor3 2691614 | Posted 2006-09-16 03:47 |
| 初级用户 Posts 11 Credits 30 | |
|
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! |
|
| Floor4 electronixtar | Posted 2006-09-16 04:02 |
| 铂金会员 Posts 2,672 Credits 7,493 | |
| Floor5 2691614 | Posted 2006-09-16 04:05 |
| 初级用户 Posts 11 Credits 30 | |
|
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. Attachments Image00000.jpg (80.12 KiB) |
|
| Floor6 2691614 | Posted 2006-09-16 04:06 |
| 初级用户 Posts 11 Credits 30 | |
|
OK, thank you. Just two % signs are enough!!!
Haha, thank you! I'm a novice, learned something new! |
|
| Floor7 2691614 | Posted 2006-09-16 04:12 |
| 初级用户 Posts 11 Credits 30 | |
|
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.
|
|
| Floor8 2691614 | Posted 2006-09-16 04:52 |
| 初级用户 Posts 11 Credits 30 | |
|
Okay, found it. Thanks!
|
|
| Floor9 electronixtar | Posted 2006-09-16 08:52 |
| 铂金会员 Posts 2,672 Credits 7,493 | |
|
Reply to floor 7:
Just run set yourself and see. The answer is: %ProgramFiles% |
|
|
[ Contact the Union admin team -
中国DOS联盟 -
Standard version ] Sponsored by ifanr Inc | © 2001–2023 |