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-06-22 13:14
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » 请问这个带有选择项的批处理是怎么样实现的 请问这个带有选择项的批处理是怎么样实现的 请问这个带有选择项的批处理是怎么样实现的 What is the way to implement this batch processing with options? What is the way to implement this batch processing with options? What is the way to implement this batch processing with options? View 3,622 Replies 35
Original Poster Posted 2006-11-02 08:50 ·  中国 福建 泉州 晋江市 电信
初级用户
Credits 97
Posts 40
Joined 2006-11-01 13:59
19-year member
UID 69168
Gender Male
Status Offline
CLSERVICE1
NET START VMNETUSERIF
NET START VMNETBRIDGE
GOTO MENU

:SERVICE2
NET START HCMON
NET START VMPARPORT
GOTO MENU

:SERVICE3
SC CREATE VMnetDHCP BINPATH= "%WINDIR%\SYSTEM32\VMNETDHCP.EXE" DISPLAYNAME= "VMware DHCP Service" DEPEND= VMnetuserif
SC CREATE "VMware NAT Service" BINPATH= "%WINDIR%\SYSTEM32\VMNAT.EXE" DISPLAYNAME= "VMware NAT Service" DEPEND= VMnetuserif
NET START VMnetDHCP
NET START "VMware NAT Service"
GOTO MENU

:SERVICE4
SC CREATE VMAuthdService BINPATH= "%CD%\VMWARE-AUTHD.EXE" DISPLAYNAME= "VMware Authorization Service" DEPEND= vmx86
NET START VMAUTHDSERVICE
GOTO MENU

:SERVICE5
NET START VMNETUSERIF
NET START VMNETBRIDGE
SC CREATE VMnetDHCP BINPATH= "%WINDIR%\SYSTEM32\VMNETDHCP.EXE" DISPLAYNAME= "VMware DHCP Service" DEPEND= VMnetuserif
SC CREATE "VMware NAT Service" BINPATH= "%WINDIR%\SYSTEM32\VMNAT.EXE" DISPLAYNAME= "VMware NAT Service" DEPEND= VMnetuserif
NET START VMnetDHCP
NET START "VMware NAT Service"
NET START HCMON
NET START VMPARPORT
SC CREATE VMAuthdService BINPATH= "%CD%\VMWARE-AUTHD.EXE" DISPLAYNAME= "VMware Authorization Service" DEPEND= vmx86
NET START VMAUTHDSERVICE
GOTO MENU

:SERVICE6
DEVCON -R INSTALL %SYSTEMROOT%\INF\VMNETADAPTER.INF *VMnetAdapter1
DEVCON -R INSTALL %SYSTEMROOT%\INF\VMNETADAPTER.INF *VMnetAdapter8
GOTO MENU

:END

[ Last edited by namejm on 2006-11-2 at 09:37 AM ]
Floor 2 Posted 2006-11-02 09:25 ·  中国 湖北 武汉 电信
版主
★★★★★
Credits 11,386
Posts 4,938
Joined 2006-07-23 17:10
19-year member
UID 59080
Status Offline

  It mainly makes use of the characteristics of the choice command to be realized, but the xp system seems not to have this command by default.


[ Last edited by lxmxn on 2006-11-2 at 09:27 AM ]
Floor 3 Posted 2006-11-02 10:49 ·  中国 北京 鹏博士BGP
中级用户
★★
Credits 404
Posts 179
Joined 2006-03-30 14:44
20-year member
UID 53056
Status Offline


  1. CLS
  2. COLOR 0A
  3. GOTO MENU

  4. :MENU
  5. ECHO.
  6. ECHO. =-=-=-=-=Please select the service item to start=-=-=-=-=
  7. ECHO.
  8. ECHO. 1 Start - Local network service
  9. ECHO.
  10. ECHO. 2 Start - USB and COM service
  11. ECHO.
  12. ECHO. 3 Start - DHCP and NAT service
  13. ECHO.
  14. ECHO. 4 Start - User permission service
  15. ECHO.
  16. ECHO. 5 Start - Start all services
  17. ECHO.
  18. ECHO. 6 Install virtual network cards 1 and 8
  19. ECHO.
  20. ECHO. 7 Exit
  21. ECHO.
  22. ECHO.
  23. ECHO.
  24. set /p in = Please enter the serial number of the selected item:
  25. IF [%in%] == GOTO SERVICE1
  26. IF [%in%] == GOTO SERVICE2
  27. IF [%in%] == GOTO SERVICE3
  28. IF [%in%] == GOTO SERVICE4
  29. IF [%in%] == GOTO SERVICE5
  30. IF [%in%] == GOTO SERVICE6
  31. IF [%in%] == GOTO END
  32. PAUSE >nul

  33. :SERVICE1
  34. NET START VMNETUSERIF
  35. NET START VMNETBRIDGE
  36. GOTO MENU

  37. :SERVICE2
  38. NET START HCMON
  39. NET START VMPARPORT
  40. GOTO MENU

  41. :SERVICE3
  42. SC CREATE VMnetDHCP BINPATH= "%WINDIR%\SYSTEM32\VMNETDHCP.EXE" DISPLAYNAME= "VMware DHCP Service" DEPEND= VMnetuserif
  43. SC CREATE "VMware NAT Service" BINPATH= "%WINDIR%\SYSTEM32\VMNAT.EXE" DISPLAYNAME= "VMware NAT Service" DEPEND= VMnetuserif
  44. NET START VMnetDHCP
  45. NET START "VMware NAT Service"
  46. GOTO MENU

  47. :SERVICE4
  48. SC CREATE VMAuthdService BINPATH= "%CD%\VMWARE-AUTHD.EXE" DISPLAYNAME= "VMware Authorization Service" DEPEND= vmx86
  49. NET START VMAUTHDSERVICE
  50. GOTO MENU

  51. :SERVICE5
  52. NET START VMNETUSERIF
  53. NET START VMNETBRIDGE
  54. SC CREATE VMnetDHCP BINPATH= "%WINDIR%\SYSTEM32\VMNETDHCP.EXE" DISPLAYNAME= "VMware DHCP Service" DEPEND= VMnetuserif
  55. SC CREATE "VMware NAT Service" BINPATH= "%WINDIR%\SYSTEM32\VMNAT.EXE" DISPLAYNAME= "VMware NAT Service" DEPEND= VMnetuserif
  56. NET START VMnetDHCP
  57. NET START "VMware NAT Service"
  58. NET START HCMON
  59. NET START VMPARPORT
  60. SC CREATE VMAuthdService BINPATH= "%CD%\VMWARE-AUTHD.EXE" DISPLAYNAME= "VMware Authorization Service" DEPEND= vmx86
  61. NET START VMAUTHDSERVICE
  62. GOTO MENU

  63. :SERVICE6
  64. DEVCON -R INSTALL %SYSTEMROOT%\INF\VMNETADAPTER.INF *VMnetAdapter1
  65. DEVCON -R INSTALL %SYSTEMROOT%\INF\VMNETADAPTER.INF *VMnetAdapter8
  66. GOTO MENU

  67. :END

  68. Code not tested
kcdsw Posted on: 2006-11-01 22:53
Floor 4 Posted 2006-11-02 10:51 ·  中国 广东 清远 联通
高级用户
★★
Credits 846
Posts 247
Joined 2006-10-27 12:03
19-year member
UID 68504
Gender Male
From 湖南==》广东
Status Offline
In Windows 2000/XP, there is no `choice` command. To achieve the function described by the thread starter, you can use `set /P`
Floor 5 Posted 2006-11-02 12:03 ·  中国 福建 泉州 晋江市 电信
初级用户
Credits 97
Posts 40
Joined 2006-11-01 13:59
19-year member
UID 69168
Gender Male
Status Offline
Strangely, adding this file can run in WINDOWS, but no matter whether choice.exe or choice.com is added, it cannot run in DOS.
Floor 6 Posted 2006-11-02 12:14 ·  中国 湖北 武汉 电信
版主
★★★★★
Credits 11,386
Posts 4,938
Joined 2006-07-23 17:10
19-year member
UID 59080
Status Offline

Where did you put the chioce.exe?
Floor 7 Posted 2006-11-02 12:35 ·  中国 福建 泉州 晋江市 电信
初级用户
Credits 97
Posts 40
Joined 2006-11-01 13:59
19-year member
UID 69168
Gender Male
Status Offline
TO:lxmxn
Add to the virtual memory disk generated by the 98 startup disk, in the root directory of this disk along with the batch file.

TO:kcdsw
Thank you for writing this batch file, but it still didn't succeed. No matter which value is selected, it still executes the first one.
Floor 8 Posted 2006-11-02 12:56 ·  中国 广东 清远 联通
高级用户
★★
Credits 846
Posts 247
Joined 2006-10-27 12:03
19-year member
UID 68504
Gender Male
From 湖南==》广东
Status Offline
If you add a detection statement and then directly use a goto :service%in%, wouldn't that be much simpler?
Floor 9 Posted 2006-11-02 13:08 ·  中国 湖北 武汉 电信
版主
★★★★★
Credits 11,386
Posts 4,938
Joined 2006-07-23 17:10
19-year member
UID 59080
Status Offline

Should it be added to the system folder?
Floor 10 Posted 2006-11-02 13:13 ·  中国 福建 泉州 晋江市 电信
初级用户
Credits 97
Posts 40
Joined 2006-11-01 13:59
19-year member
UID 69168
Gender Male
Status Offline
This I don't understand, I don't even know where the addition is.
Floor 11 Posted 2006-11-02 13:16 ·  中国 福建 泉州 晋江市 电信
初级用户
Credits 97
Posts 40
Joined 2006-11-01 13:59
19-year member
UID 69168
Gender Male
Status Offline
Originally posted by lxmxn at 2006-11-2 01:08 PM:

Should it be added to the system folder?



The system starts searching for the required files from the folder where it is located, and only goes to the system folder if it can't find them. DOS should be no exception. Also, I want to put this batch file on the boot disk, so there is no such thing as a system folder at all
Floor 12 Posted 2006-11-02 20:38 ·  中国 四川 南充 电信
超级版主
★★★★
我爱DOS
Credits 5,310
Posts 2,044
Joined 2005-09-26 12:00
20-year member
UID 42843
Gender Male
From 四川南充
Status Offline
Floor 13 Posted 2006-11-02 21:24 ·  中国 上海 松江区 电信
铂金会员
★★★★
DOS一根葱
Credits 5,493
Posts 2,315
Joined 2006-05-01 10:41
20-year member
UID 54766
Gender Male
From 上海
Status Offline
AUTOEXEC.BAT, NET START I'm wondering whether this batch file is run under pure DOS or in XP?
第一高手 第二高手

Floor 14 Posted 2006-11-02 22:04 ·  中国 福建 泉州 晋江市 电信
初级用户
Credits 97
Posts 40
Joined 2006-11-01 13:59
19-year member
UID 69168
Gender Male
Status Offline
Does choice not work in a VM and must be used on a physical machine?
Floor 15 Posted 2006-11-02 22:13 ·  中国 上海 松江区 电信
铂金会员
★★★★
DOS一根葱
Credits 5,493
Posts 2,315
Joined 2006-05-01 10:41
20-year member
UID 54766
Gender Male
From 上海
Status Offline
CHOICE extracted from Win2003
http://www.cn-dos.net/forum/viewthread.php?tid=21689&fpage=1&highlight=choice

What system is in the VM? Be sure to clarify whether it's a pure DOS batch or a CMD (XP) batch. There are essential differences between the two
第一高手 第二高手

Forum Jump: