|
augvii
初级用户
 
积分 38
发帖 17
注册 2008-4-10
状态 离线
|
『楼 主』:
如何查询出软件SQLServer2000的安装路径?
使用 LLM 解释/回答一下
比如如何查出sqlserver安装的路径?
我用了下面的语句但是除了路径,还有其它信息,请问还有什么方法能直接查出路径吗?
-----------------------------------------------------------------------------------------------------------------
FOR /F "delims=" %%i IN ('@reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSSQLServer\Setup" /v
SQLPath') DO @SET mypath=%%i
-----------------------------------------------------------------------------------------------------------------
Last edited by augvii on 2008-9-28 at 11:41 ]
For example, how to find out the installation path of SQL Server?
I used the following statement, but there are other information besides the path. Is there any other method to directly find out the path?
-----------------------------------------------------------------------------------------------------------------
FOR /F "delims=" %%i IN ('@reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSSQLServer\Setup" /v
SQLPath') DO @SET mypath=%%i
-----------------------------------------------------------------------------------------------------------------
Last edited by augvii on 2008-9-28 at 11:41 ]
|
|
2008-9-23 19:52 |
|
|
augvii
初级用户
 
积分 38
发帖 17
注册 2008-4-10
状态 离线
|
『第 2 楼』:
使用 LLM 解释/回答一下
难道是我没描述清楚?我想查出安装sqlserver2000的安装路径,再传给一个变量。但是按照上面的方法,得到的是“ SQLPath REG_SZ C:\Program Files\Microsoft SQL Server\MSSQL.2\MSSQL “。我想得到C:\Program Files\Microsoft SQL Server\MSSQL.2\MSSQL,批处理该如何写?(注意:后面是没带空格的)
Is it that I didn't describe clearly? I want to find out the installation path of installing SQL Server 2000 and then pass it to a variable. But according to the above method, what is obtained is " SQLPath REG_SZ C:\Program Files\Microsoft SQL Server\MSSQL.2\MSSQL ". I want to get C:\Program Files\Microsoft SQL Server\MSSQL.2\MSSQL, how should the batch processing be written? (Note: there is no space at the end)
|
|
2008-9-23 20:44 |
|
|
HAT
版主
       
积分 9023
发帖 5017
注册 2007-5-31
状态 离线
|
『第 3 楼』:
使用 LLM 解释/回答一下
@echo off
for /f "skip=4 tokens=1,2 delims=:" %%a in ('reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSSQLServer\Setup" /v "SQLPath"') do (
set SQLL=%%a
set SQLR=%%b
)
set SQL=%SQLL:~-1%:%SQLR%
echo %SQL%
```@echo off
for /f "skip=4 tokens=1,2 delims=:" %%a in ('reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSSQLServer\Setup" /v "SQLPath"') do (
set SQLL=%%a
set SQLR=%%b
)
set SQL=%SQLL:~-1%:%SQLR%
echo %SQL%
```
|

 |
|
2008-9-23 20:49 |
|
|
augvii
初级用户
 
积分 38
发帖 17
注册 2008-4-10
状态 离线
|
『第 4 楼』:
使用 LLM 解释/回答一下
谢谢,HAT.
CN-DOS上的人果然很热心。查了一下午都没结果,没想到在这10分钟就搞定了。
Thanks, HAT.
People on CN-DOS are really helpful. I spent the whole afternoon without getting results, but didn't expect it to be done in 10 minutes here.
|
|
2008-9-23 20:58 |
|
|
everest79
金牌会员
      一叶枝头,万树皆春
积分 2564
发帖 1127
注册 2006-12-25
状态 离线
|
『第 5 楼』:
使用 LLM 解释/回答一下
你查下本地变量path中应有安装路径
Please check that the installation path should be in the local variable path
|

49206C6F766520796F752067757973 54656C3A3133383238343036373837 |
|
2008-9-24 03:43 |
|
|
augvii
初级用户
 
积分 38
发帖 17
注册 2008-4-10
状态 离线
|
『第 6 楼』:
使用 LLM 解释/回答一下
To everest79:path里取的值好像不是安装路径。我是想取sqlserver数据库文件的存放目录
To everest79: The value taken from the path doesn't seem to be the installation path. I want to get the storage directory of the SQL Server database files
|
|
2008-9-24 09:35 |
|
|
augvii
初级用户
 
积分 38
发帖 17
注册 2008-4-10
状态 离线
|
『第 7 楼』:
使用 LLM 解释/回答一下
to HAT:那段代码有点奇怪,一台机器上都取得了,但在另一台机器上,就取不全了。难道reg真的会漏字符?可是不是中文路径啊?
还想问一下,%%b,是在什么时候取值的?
Last edited by augvii on 2008-9-24 at 09:39 AM ]
to HAT: That code is a bit strange. It's retrieved on one machine, but not fully retrieved on another. Could it be that reg really misses characters? But it's not a Chinese path?
Also, I want to ask, when is %%b evaluated?
Last edited by augvii on 2008-9-24 at 09:39 AM ]
|
|
2008-9-24 09:38 |
|
|
HAT
版主
       
积分 9023
发帖 5017
注册 2007-5-31
状态 离线
|
『第 8 楼』:
Re 7楼
使用 LLM 解释/回答一下
对于漏字符的机器,系统版本是什么?
你可以到注册表编辑器里面看看是否真的有中文:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSSQLServer\Setup\SQLPath
另,昨晚在群里提到的那个调用VBS来读注册表的代码会不会出现同样的问题?
What is the system version for machines with missing characters?
You can go to the Registry Editor to see if there are really Chinese characters:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSSQLServer\Setup\SQLPath
Also, will the code that calls VBS to read the registry mentioned in the group last night have the same problem?
|

 |
|
2008-9-24 09:44 |
|
|
augvii
初级用户
 
积分 38
发帖 17
注册 2008-4-10
状态 离线
|
『第 9 楼』:
使用 LLM 解释/回答一下
没有中文
用三楼的代码这台机器出现:
~-1SQLR\Data
--------------------------------------------------------
@echo off
>"%temp%\my.vbs"
echo Set WshShell = WScript.CreateObject("WScript.Shell")
>>"%temp%\my.vbs"
echo WScript.Echo WshShell.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSSQLServer\Setup")
for /f "delims=" %%a in ('cscript /nologo "%temp%\my.vbs"') do set SQL=%%a
echo %SQL%
pause
--------------------------------------------------------------------------------------------
这个代码看不到效果啊,一闪而过。
There is no Chinese. Using the code from the third floor, this machine has:
~-1SQLR\Data
--------------------------------------------------------
@echo off
>"%temp%\my.vbs"
echo Set WshShell = WScript.CreateObject("WScript.Shell")
>>"%temp%\my.vbs"
echo WScript.Echo WshShell.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSSQLServer\Setup")
for /f "delims=" %%a in ('cscript /nologo "%temp%\my.vbs"') do set SQL=%%a
echo %SQL%
pause
--------------------------------------------------------------------------------------------
This code doesn't see the effect, it flashes by.
|
|
2008-9-24 09:56 |
|
|
HAT
版主
       
积分 9023
发帖 5017
注册 2007-5-31
状态 离线
|
『第 10 楼』:
Re 9楼
使用 LLM 解释/回答一下
出问题的机器,版本是什么?
在那台机器上运行这个代码,把结果贴出来看看:
for /f "skip=4 tokens=1,2 delims=:" %%a in ('reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSSQLServer\Setup" /v "SQLPath"') do (
set SQLL=%%a
set SQLR=%%b
)
set SQL=%SQLL:~-1%:%SQLR%
echo %SQL%
pause
调用VBS的代码,是不是应该这样:
@echo off
>"%temp%\my.vbs" echo Set WshShell = WScript.CreateObject("WScript.Shell")
>>"%temp%\my.vbs" echo WScript.Echo WshShell.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSSQLServer\Setup\SQLPath")
for /f "delims=" %%a in ('cscript /nologo "%temp%\my.vbs"') do set SQL=%%a
echo %SQL%
pause
What is the version of the machine with the problem?
Run this code on that machine and post the result:
for /f "skip=4 tokens=1,2 delims=:" %%a in ('reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSSQLServer\Setup" /v "SQLPath"') do (
set SQLL=%%a
set SQLR=%%b
)
set SQL=%SQLL:~-1%:%SQLR%
echo %SQL%
pause
Should the code for calling VBS be like this:
@echo off
>"%temp%\my.vbs" echo Set WshShell = WScript.CreateObject("WScript.Shell")
>>"%temp%\my.vbs" echo WScript.Echo WshShell.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSSQLServer\Setup\SQLPath")
for /f "delims=" %%a in ('cscript /nologo "%temp%\my.vbs"') do set SQL=%%a
echo %SQL%
pause
|

 |
|
2008-9-24 10:13 |
|
|
augvii
初级用户
 
积分 38
发帖 17
注册 2008-4-10
状态 离线
|
『第 11 楼』:
使用 LLM 解释/回答一下
第一个代码运行结果:
~-1SQLR\Data
--------------------------------------------------------------------------
第二个代码成功取出:
C:\Program Files\Microsoft SQL Server\MSSQL.2\MSSQL
---------------------------------------------------------------------------
我本想取得sqlserver目录下的Date文件的路径,即存放数据库文件的目录。
现在数据库sqlserver2000安装时数据目录和安装目录分开的。
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSSQLServer\Setup\SQLPath查出的是安装目录。不知道存放数据库文件的目录应该查看注册表的哪一项?
The first code running result:
~-1SQLR\Data
--------------------------------------------------------------------------
The second code successfully fetched:
C:\Program Files\Microsoft SQL Server\MSSQL.2\MSSQL
---------------------------------------------------------------------------
I originally wanted to obtain the path of the Date file under the sqlserver directory, that is, the directory where database files are stored.
Now when SQL Server 2000 is installed, the data directory and the installation directory are separated.
The SQLPath found in HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSSQLServer\Setup\SQLPath is the installation directory. I don't know which item in the registry should be checked to find the directory where database files are stored?
|
|
2008-9-24 10:30 |
|
|
augvii
初级用户
 
积分 38
发帖 17
注册 2008-4-10
状态 离线
|
『第 12 楼』:
使用 LLM 解释/回答一下
sqlserver2000数据库文件存放目录对应注册表查到了
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSSQLServer\Setup\SQLDataRoot
现在用VBS可以实现了。谢谢
但我想问下cscript /nologo 是什么意思啊?
The `/nologo` option for `cscript` is used to suppress the Microsoft Visual Basic Script host logo from being displayed when the script is run.
|
|
2008-9-24 10:41 |
|
|
HAT
版主
       
积分 9023
发帖 5017
注册 2007-5-31
状态 离线
|
『第 13 楼』:
使用 LLM 解释/回答一下
Re 11楼:
把10楼的第一段代码保存为test.bat,双击运行,把完整结果贴出来看看。
Re 12楼:
看看帮助
cscript /?
Re 11th floor:
Save the first paragraph of the code on the 10th floor as test.bat, double-click to run it, and post the complete result for us to see.
Re 12th floor:
Check the help
cscript /?
|

 |
|
2008-9-24 11:16 |
|
|
augvii
初级用户
 
积分 38
发帖 17
注册 2008-4-10
状态 离线
|
『第 14 楼』:
使用 LLM 解释/回答一下
C:\Documents and Settings\Administrator\桌面\sqltest-augvii>for /F "skip=4 token
s=1,2 delims=:" %a in ('reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSSQLSe
rver\Setup" /v "SQLPath"') do (
set SQLL=%a
set SQLR=%b
)
C:\Documents and Settings\Administrator\桌面\sqltest-augvii>set SQL=~-1SQLR
C:\Documents and Settings\Administrator\桌面\sqltest-augvii>echo ~-1SQLR
~-1SQLR
C:\Documents and Settings\Administrator\桌面\sqltest-augvii>pause
请按任意键继续. . .
我是放在桌面运行的,刚刚复制到d:\也是不行。。。
==================================================
还有个问题:copy xx.txt %SQL% 有错吗? (xx.txt为同一目录下的文件,SQL为赋了一个路径的变量)
Last edited by augvii on 2008-9-24 at 12:11 PM ]
C:\Documents and Settings\Administrator\Desktop\sqltest-augvii>for /F "skip=4 tokens=1,2 delims=:" %a in ('reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSSQLServer\Setup" /v "SQLPath"') do (
set SQLL=%a
set SQLR=%b
)
C:\Documents and Settings\Administrator\Desktop\sqltest-augvii>set SQL=~-1SQLR
C:\Documents and Settings\Administrator\Desktop\sqltest-augvii>echo ~-1SQLR
~-1SQLR
C:\Documents and Settings\Administrator\Desktop\sqltest-augvii>pause
Press any key to continue . . .
I put it on the desktop and ran it. Just now, I copied it to d:\ and it didn't work...
==================================================
Another question: Is there a mistake in copy xx.txt %SQL% ? (xx.txt is a file in the same directory, SQL is a variable assigned a path)
Last edited by augvii on 2008-9-24 at 12:11 PM ]
|
|
2008-9-24 12:07 |
|
|
HAT
版主
       
积分 9023
发帖 5017
注册 2007-5-31
状态 离线
|
『第 15 楼』:
Re 14楼
使用 LLM 解释/回答一下
开始
运行
cmd
reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSSQLServer\Setup" /v "SQLPath"
结果是什么?如果没有结果,请检查这台机器是否安装了SQL Server 2000
路径有空格的时候记得加引号:
copy "xx.txt" "%SQL%"
Start
Run
cmd
reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSSQLServer\Setup" /v "SQLPath"
What is the result? If there is no result, please check if this machine has SQL Server 2000 installed.
When the path has spaces, remember to add quotes:
copy "xx.txt" "%SQL%"
|

 |
|
2008-9-24 13:37 |
|