|
chishingchan
银牌会员
积分 1282
发帖 538
注册 2002-11-2
状态 离线
|
『楼 主』:
[已结] 如何显示带&的字符串?
请看例子:
@echo off
REG QUERY "HKLM\SYSTEM\CurrentControlSet\Services\Kbdclass\Enum" /v 1
Quote: | ! REG.EXE VERSION 3.0
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Kbdclass\Enum
1 REG_SZ ACPI\PNP0303\4&30647147&0
请按任意键继续. . . |
|
@echo off
REG QUERY "HKLM\SYSTEM\CurrentControlSet\Services\Kbdclass\Enum" /v 1
for /f "tokens=3" %%a in ('REG QUERY "HKLM\SYSTEM\CurrentControlSet\Services\Kbdclass\Enum" /v 1 ^|findstr "REG_SZ"') do @set K1=%%a
echo %K1%
pause
Quote: | ! REG.EXE VERSION 3.0
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Kbdclass\Enum
1 REG_SZ ACPI\PNP0303\4&30647147&0
ACPI\PNP0303\4
'30647147' 不是内部或外部命令,也不是可运行的程序
或批处理文件。
'0' 不是内部或外部命令,也不是可运行的程序
或批处理文件。
请按任意键继续. . . |
|
请教如何修正这个错误?谢谢!
———————————————————————
转移自 DOS疑难解答 & 问题讨论 (解答室)
明显发错版块,予以扣分处理。
——管理员
———————————————————————
[ Last edited by chishingchan on 2009-2-12 at 01:26 ]
|
|
2009-2-10 12:43 |
|
|
chishingchan
银牌会员
积分 1282
发帖 538
注册 2002-11-2
状态 离线
|
『第
2 楼』:
没办法,版块的分类好像有点含糊,因我这问题相关DOS批处理和WIN注册表。扣分不要紧,买个教训,但最希望的能够解决问题。
|
|
2009-2-10 20:06 |
|
|
DOSroot
管理员
积分 389
发帖 198
注册 2008-9-23
状态 离线
|
『第
3 楼』:
没有关系,如果我扣错了可以给你加回。
让我们来讨论下你的问题的范畴。确实,有时候用 DOS 的方式来解决 Windows 的问题我也觉得困惑,这到底算是 DOS 问题呢还是 Windows 问题?但你这个问题我确实看不出哪里和 DOS 有关。
如果今后类似的问题你想用批处理的方式来解决,可以发到“批处理室”。
|
|
2009-2-10 20:44 |
|
|
chishingchan
银牌会员
积分 1282
发帖 538
注册 2002-11-2
状态 离线
|
『第
4 楼』:
怎么说呢?这里是讨论区,我的问题在《DOS疑难解答 & 问题讨论 (解答室) 》也好像合理。反正这不重要,积分扣了不打紧,管理员能否帮忙解决这个问题呢?
还有的是CMD的命令属于WINDOWS还是属于DOS的范畴呢?
[ Last edited by chishingchan on 2009-2-10 at 22:05 ]
|
|
2009-2-10 22:01 |
|
|
DOSroot
管理员
积分 389
发帖 198
注册 2008-9-23
状态 离线
|
『第
5 楼』:
Quote: | Originally posted by chishingchan at 2009-2-10 22:01:
还有的是CMD的命令属于WINDOWS还是属于DOS的范畴呢? |
|
作为一个差不多和论坛成立时间就注册的,并且已经是到了“银牌会员”等级会员,提出这样的问题不得不让我感到吃惊。
我想 willsort 你应该一定认识吧,如果你对这方面概念不清楚,请看一下他的帖子:
http://www.cn-dos.net/forum/viewthread.php?tid=20682
只要看第一段就可以了。
|
|
2009-2-10 22:39 |
|
|
chishingchan
银牌会员
积分 1282
发帖 538
注册 2002-11-2
状态 离线
|
『第
6 楼』:
这篇文章写的太好了,就像是他本人对自己的软件描述一样,第一次浏览到,受教了。
2002年注册的,银牌会员算少了,我之前因忘记密码还注册了个chishing,等级是什么忘了,再加上在本坛也不算很活跃,有时遇到困难才想到来这里,衷心讲句,本坛让我学习的知识对我帮助是很大的,也感谢热心的版主们对我的问题给于解答,谢谢!
其实本坛的许多资深的会员也会像我一样,不时每次上网都到这里的,因为有时我答复的帖子、提出的疑问难题也是等了很久才会有回应的。
我也自认年纪大了点,许多命令或者技巧不是说想用就能用上,要查看例子才能编出程序来,就像是开卷考试翻书一样。况且DOS对我只是辅助而已,想出个软件难道懂DOS就能编个程序去卖吗?DOS做不到。
我现时也在学习VBS,毕竟对于Windows下辅助性比DOS更大,也有了一点儿成绩,但也是要查看资料才能编写,因为记不住。
说得太多了。。。
言归正传,楼顶的问题管理员可否帮忙一下呢?
|
|
2009-2-11 01:49 |
|
|
HAT
版主
积分 9023
发帖 5017
注册 2007-5-31
状态 离线
|
『第
7 楼』:
Quote: | @echo off
REG QUERY "HKLM\SYSTEM\CurrentControlSet\Services\Kbdclass\Enum" /v 1
for /f "tokens=3" %%a in ('REG QUERY "HKLM\SYSTEM\CurrentControlSet\Services\Kbdclass\Enum" /v 1 ^|findstr "REG_SZ"') do @set K1=%%a
echo "%K1%"
pause |
|
[ Last edited by HAT on 2009-2-11 at 05:20 ]
|
|
|
2009-2-11 05:18 |
|
|
chishingchan
银牌会员
积分 1282
发帖 538
注册 2002-11-2
状态 离线
|
『第
8 楼』:
谢谢HAT版主的解答,但还不太行,因为获取的值还有用途
@echo off
REG QUERY "HKLM\SYSTEM\CurrentControlSet\Services\Kbdclass\Enum" /v 1
for /f "tokens=3" %%a in ('REG QUERY "HKLM\SYSTEM\CurrentControlSet\Services\Kbdclass\Enum" /v 1 ^|findstr "REG_SZ"') do @set K1=%%a
echo "%K1%"
pause
Quote: | ! REG.EXE VERSION 3.0
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Kbdclass\Enum
1 REG_SZ ACPI\PNP0303\4&30647147&0
"ACPI\PNP0303\4&30647147&0"
请按任意键继续. . . |
|
获取变量赋于参数的一部分,添加一个多字符串值:
REG ADD "HKLM,SYSTEM\CurrentControlSet\Enum\%K1%" /v UpperFilters /t REG_MULTI_SZ /d BeTwinKeyboard
[ Last edited by chishingchan on 2009-2-11 at 09:24 ]
|
|
2009-2-11 09:05 |
|
|
HAT
版主
积分 9023
发帖 5017
注册 2007-5-31
状态 离线
|
『第
9 楼』:
Re 8楼
@echo off
REG QUERY "HKLM\SYSTEM\CurrentControlSet\Services\Kbdclass\Enum" /v 1
for /f "tokens=3" %%a in ('REG QUERY "HKLM\SYSTEM\CurrentControlSet\Services\Kbdclass\Enum" /v 1 ^|findstr "REG_SZ"') do (
REG ADD "HKLM\SYSTEM\CurrentControlSet\Enum\%%a" /v UpperFilters /t REG_MULTI_SZ /d BeTwinKeyboard
)
pause
|
|
|
2009-2-11 13:08 |
|
|
chishingchan
银牌会员
积分 1282
发帖 538
注册 2002-11-2
状态 离线
|
『第
10 楼』:
Quote: | Originally posted by HAT at 2009-2-11 01:08 PM:
[code]@echo off
REG QUERY "HKLM\SYSTEM\CurrentControlSet\Services\Kbdclass\Enum" /v 1
for /f "tokens=3" %%a in ('REG QUERY "HKLM\SYSTEM\CurrentControlSet\Services\Kbdclas ... |
|
谢谢!我想应该可以的,但是我也说不清原因,此项居然拒绝访问。
系统:XP SP2
用户:Administrator
运行后:
Quote: | ! REG.EXE VERSION 3.0
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Kbdclass\Enum
1 REG_SZ ACPI\PNP0303\4&30647147&0
Error: 拒绝访问。
请按任意键继续. . . |
|
|
|
2009-2-11 13:12 |
|
|
HAT
版主
积分 9023
发帖 5017
注册 2007-5-31
状态 离线
|
『第
11 楼』:
Re 10楼
是的,默认情况下everyone对该分支的权限是read,你可以用regini命令修改其权限。
|
|
|
2009-2-11 20:53 |
|
|
chishingchan
银牌会员
积分 1282
发帖 538
注册 2002-11-2
状态 离线
|
『第
12 楼』:
Quote: | Originally posted by HAT at 2009-2-11 08:53 PM:
是的,默认情况下everyone对该分支的权限是read,你可以用regini命令修改其权限。 |
|
regini 这东西直接运行没反应,加 /?也没反应。请教如何修改权限呢?
|
|
2009-2-11 22:05 |
|
|
HAT
版主
积分 9023
发帖 5017
注册 2007-5-31
状态 离线
|
|
2009-2-11 22:15 |
|
|
chishingchan
银牌会员
积分 1282
发帖 538
注册 2002-11-2
状态 离线
|
『第
14 楼』:
成功!在网上还找到另一篇说明:
REGINI.EXE
Microsoft® Windows NT™ Resource Kit Utility
Documentation
Copyright © Microsoft Corp. 1993-1997
Contents
1. Introduction
2. Command-line syntax
3. Creating a REGINI script file
3.1 Script-file syntax
3.2 Line formatting
3.3 Key names
3.3.1 Key name syntax
3.3.2 Kernel and User key names
3.4 ACLs
3.5 Values
4. Sample script files
4.1 Bypassing the automatic logon feature
4.2 Adding a mail key value for the current user
4.2.1 Example 1
4.2.2 Example 2
4.3 Setting the default name
4.4 Complex sample
1. Introduction
REGINI.EXE is a character-based utility that you can use to add and modify keys and values in the Windows NT Registry by specifying a Registry script. This document details and provides examples of how to run REGINI and how to create script files for it.
Wherever possible, you should use Control Panel and applications in the Administrative Tools program group to make changes to the system configuration and thus to the Registry. When you want functionality similar to that of REGINI in an interactive process, use the Windows NT Registry Editors, REGEDT32.EXE and REGEDIT.EXE.
When you need to automate the process of modifying the Registry, however, REGINI provides a way to add or modify values in the Registry with scripts that you can write. For example, you can use REGINI for batch implementation of corporate standards such as background bitmaps, sounds, and security settings. For installing new device drivers or hardware, though, it is preferable to use the Setup application programming interfaces (APIs) provided for that purpose.
2. Command-line syntax
To run REGINI, type at the command prompt:
regini [InputTextFile] [InputTextFile] [... InputTextFile]
where:
InputTextFile
is the filename (and optionally the path) of one or more script files to be processed into the Windows NT Registry. The filename can have any extension or none.
Script files must be in ANSI format, but are converted to Unicode when read from the disk. Currently, you cannot specify a Unicode text file as the script file.
For example:
regini \\myserver\public\myfolder\srv.ini
saves a file named SRV.INI in the shared folder \\myserver\public\myfolder\.
3. Creating a REGINI script file
3.1 Script-file syntax
In a REGINI script file specifying Registry changes, you must locate the new or changed key on the first line followed by the value of that key on the second line, in this format:
\Registry\Key [ACL]
ValueName = DataType ValueData
The elements of this syntax are explained in sections 3.3 through 3.5.
If a line does not contain an equal sign (=), then REGINI interprets that line as specifying a Registry key name.
If a line contains an equal sign (=), then REGINI interprets that line as specifying a Registry value.
Note: Make sure the text editor you use to create the script file puts a carriage return at the end of each line. Lack of carriage returns can cause unpredictable results.
For example, a REGINI script file named SRV.INI saved on the shared directory \\myserver\public\myfolder\ contains the following text:
\Registry\Machine\System\CurrentControlSet\Services\Lanmanserver\Parameters
DiskSpaceThreshhold = REG_DWORD 0x00000000
The following, typed at the command prompt, places the DiskSpaceThreshhold parameter in the Registry or changes the value that is already there:
regini \\myserver\public\myfolder\srv.ini
Note: The filename can have any extension or none. Script files must be in ANSI format, but are converted to Unicode when read from the disk. Currently, there is no way to specify a Unicode text file as the script file.
3.2 Line formatting
The format of the script file is line-oriented. If you are unable to fit all the information for a Registry key name or value on a line, use the backslash character (\) as a line-continuation character.
For example:
123456\
1234 \
12
is treated as single line containing:
1234561234 12
3.3 Key names
3.3.1 Key name syntax
If a line does not contain an equal sign (=), then the line specifies a Registry key name. In a REGINI script file, the key name consists of all text from the first non-blank character to the end of the line, including spaces, on any line that does not contain an equal sign.
Leading spaces are significant. If there are no leading spaces, then the named key is an absolute path from the Registry.
For example:
\Registry\Machine\Software
or
USER:Control Panel
In the second example, USER: is replaced by the full path to the root of the currently logged-on users profile (for example, \Registry\Users\S-x-x-xxxx...).
If a line in the script file does not contain an equal sign, and there are one or more spaces at the beginning of that line, then the key name on that line is defined relative to the preceding key in the Registry hierarchy. If the number of leading spaces is the same as in the preceeding key, then REGINI locates the key is at the same level. If the number is less, REGINI locates the key one level higher; if the number is more, REGINI locates the key one level lower.
For example:
\Registry\Machine\Software
Level1a
Level2a
Level2b
Level3a
Level1b
3.3.2 Kernel and User key names
Note that REGINI works with Kernel Registry strings. When you access the Registry in User mode to modify the HKEY_LOCAL_MACHINE, HKEY_CURRENT_USER, or HKEY_CURRENT_USER keys, the string is converted in Kernel mode as follows:
HKEY_LOCAL_MACHINE is converted to \Registry\Machine.
HKEY_USERS is converted to \Registry\User.
HKEY_CURRENT_USER is converted to \Registry\User\User_SID, where User_SID is the security ID (SID) associated with the current user.
3.4 ACL
After the key name, you can optionally specify an ACL (access control list). The ACL is a list of decimal numbers separated by spaces within square brackets. The decimal numbers represent the following user rights:
1 Administrator Full
2 Administrator R
3 Administrator RW
4 Administrator RWD
5 Creator Full
6 Creator RW
7 World Full
8 World R
9 World RW
10 World RWD
11 Power Users Full
12 Power Users RW
13 Power Users RWD
14 System OpFull
15 System OpRW
16 System OpRWD
17 System Full
18 System RW
19 System R
20 Administrator RWX
3.5 Values
If a line in a script contains an equal sign (=), then that line specifies a Registry value. The text to the left of the equal sign, if any, is the value name. The text to the right of the equal sign specifies the data type and value data. Syntax for a value line follows:
ValueName = DataType ValueData
The value name consists of all characters from the first non-blank character on the line to the last non-blank character before the equal sign. The value data consists of the first non-blank character after the data type to the end of the line.
Eight data-type keywords are supported. If none is specified, the default data type, REG_SZ, is used. The data types and the format of the value data for each are:
Data Type
Value Data Sets the Registry data type to
Notes
REG_SZ A string. REG_SZ REG_SZ is the default data type.
REG_EXPAND_SZ A string REG_EXPAND_SZ
REG_MULTI_SZ One or more strings, each delimited by quotes REG_MULTI_SZ
REG_MULTISZFILE A path to a file REG_MULTI_SZ The file is opened and each quoted string is added to the value data.
REG_DWORD A decimal number REG_DWORD Use 0x to specify a hexadecimal value, 0o to specify an octal value, and 0b to specify a binary value. You can also use the strings On, Yes or True, each of which is converted to 0x00000001 and the strings Off, No or False, each of which is converted to 0x00000000.
REG_BINARY Two or more decimal numbers REG_BINARY The first decimal number must be the number of bytes of data that follow. The remaining numbers are converted into 32-bit numbers. Thus, the value length should always be a multiple of 4 bytes.
REG_BINARYFILE A path to a file REG_BINARY The named file is opened and its contents stored in the Registry as the value. The length of the value will be the length of the file.
DELETE [No value data] [No data type] If this keyword is specified as the data type, the value name is deleted.
4. Sample script files
This section shows some examples of REGINI script files. The sample script files show how to modify the automatic logon feature, how to add a mail key value for the current user and how to modify several Registry keys at the same time.
4.1 Bypassing the automatic logon feature
This example shows you how to bypass the automatic logon feature of the Windows NT platform by using a REGINI script.
The problem with bypassing the automatic logon feature is that the original DefaultUserName is not kept for subsequent logons, because the name of the last user to log on is the one retained in the Username box of the Welcome dialog box and in the Registry. To reenable the AutoAdminLogon, enter the original DefaultUserName and password in the Welcome dialog box. If the original DefaultUserName and password are unknown, use REGINI.EXE to modify the parameters in the Registry to reflect the correct user name with each logon.
To ensure that the DefaultUserName value never changes, create an script file with the following text:
\Registry\Machine
Software
Microsoft
Windows NT
CurrentVersion
Winlogon
DefaultUserName = REG_SZ USERNAMETEST
where DefaultUserName is the value name, REG_SZ is the data type and USERNAMETEST is the desired result or value.
To reference the script file, create a .BAT or .CMD file containing the following command:
c:\reskit\regini c:\usernametest.ini
where the name of the script file saved is USERNAMETEST.INI.
To ensure that the DefaultUserName will not change regardless of how many users log on, you must put this .CMD or .BAT file in the Common Startup group.
4.2 Adding a mail key value for the current user
These examples show you how to add a value for the current user in the mail key.
To do so, you must first find the current user SID. Run the REGEDT32 utility and go into HKEY_USERS. You will see only two subkeys, ".DEFAULT" and the current user SID. When a user logs on, the system loads the hive corresponding to the user Registry settings. Therefore, HKEY_CURRENT_USER is simply a link to HKEY_USERS\loggeduser_sid.
The following two sample scripts show how to use this information with REGINI when you want to include multiple Registry keys.
4.2.1 Example 1
\registry\user\.DEFAULT\toto
Type = REG_DWORD 0x00000001
Start = REG_DWORD 0x00000003
Group = Extended base
ErrorControl = REG_DWORD 0x00000001
4.2.2 Example 2
\registry\user\S-1-5-21-2185238159-1414228629-1939875897-1000\toto
Type = REG_DWORD 0x00000001
Start = REG_DWORD 0x00000003
Group = Extended base
ErrorControl = REG_DWORD 0x00000001
Replace the SID in the examples with your own SID.
4.3 Setting the default name
This example, DEFLTNAM.INI, shows how to use REGINI to set the default name at the logon prompt. This script modifies HKEY_LOCAL_MACHINE.
\Registry\Machine
Software
Microsoft
Windows NT
CurrentVersion
Winlogon
DefaultUserName = REG_SZ bmiller
4.4 Complex sample
\Registry\Machine\Software
Classes
AudioCD [10 1 17 5]
EditFlags = REG_BINARY 0x00000004 0x00000002
DefaultIcon
= REG_EXPAND_SZ %SystemRoot%\system32\shell32.dll,40
shell
= play
play
= &Play
command
= REG_EXPAND_SZ %SystemRoot%\system32\cdplayer.exe \
/play %1
Microsoft
Rpc
DCOM Protocols = REG_MULTI_SZ "ncadg_ip_udp" \
"ncadg_ipx" \
"ncacn_ip_tcp" \
"ncacn_spx" \
"ncacn_nb_nb" \
"ncacn_nb_ipx"
NameService
Protocol=ncacn_np
NetworkAddress=\\.
ServerNetworkAddress=\\.
Endpoint=\pipe\locator
DefaultSyntax=3
NetBios
ServerProtocols
ncacn_np=rpclts1.dll
ncalrpc=ncalrpc
ncacn_vns=rpclts8.dll
ClientProtocols
ncacn_np=rpcltc1.dll
ncalrpc=ncalrpc
ncacn_vns=rpcltc8.dll
NetDDE [17 1]
DDE Shares
SerialNumber = REG_BINARY 8 0x09000005 0x01000000
CLPBK$
fuCmdShow = REG_DWORD 0x7
ItemList = REG_MULTI_SZ
NewStyleLink = REG_SZ
NumItems = REG_DWORD 0x0
OldStyleLink = REG_SZ
Revision = REG_DWORD 0x1
SecurityDescriptor = REG_BINARY 0x6C \
0x80040001 \
0x0000004C \
0x0000005C \
0x00000000 \
0x00000014 \
0x00380002 \
0x00000002 \
0x00180200 \
0x000F03FF \
0x00000201 \
0x05000000 \
0x00000020 \
0x00000220 \
0x00180200 \
0x000002BD \
0x00000101 \
0x01000000 \
0x00000000 \
0x00000220 \
0x00000201 \
0x05000000 \
0x00000020 \
0x00000220 \
0x00000201 \
0x05000000 \
0x00000020 \
0x00000220
SerialNumber = REG_BINARY 8 0x09000005 0x01000000
Service = REG_DWORD 0x1
SharedFlag = REG_DWORD 0x1
ShareName = REG_SZ CLPBK$
ShareType = REG_DWORD 0x4
StartAppFlag = REG_DWORD 0x0
StaticDataLink = REG_SZ ClipSrv|System
REGINI.DOC Version 0.90
Last revised: January 8, 1997
[ Last edited by chishingchan on 2009-2-12 at 01:25 ]
|
|
2009-2-12 01:14 |
|
|
netbenton
银牌会员
批处理编程迷
积分 1916
发帖 752
注册 2008-12-28 来自 广西
状态 离线
|
『第
15 楼』:
Quote: | @echo off
REG QUERY "HKLM\SYSTEM\CurrentControlSet\Services\Kbdclass\Enum" /v 1
for /f "tokens=3" %%a in ('REG QUERY "HKLM\SYSTEM\CurrentControlSet\Services\Kbdclass\Enum" /v 1 ^|findstr "REG_SZ"') do @set K1=%%a
echo %K1%
pause
|
|
关于一楼的问题,
好像这样也可以正常显示:
@echo off&setlocal enabledelayedexpansion
REG QUERY "HKLM\SYSTEM\CurrentControlSet\Services\Kbdclass\Enum" /v 1
for /f "tokens=3" %%a in ('REG QUERY "HKLM\SYSTEM\CurrentControlSet\Services\Kbdclass\Enum" /v 1 ^|findstr "REG_SZ"') do @set “K1=%%a”
echo !K1!
pause
endlocal
|
精简
[你的+我的+他的]=>[大家的] 个人网志 |
|
2009-2-13 02:38 |
|