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-08-09 20:56
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » How to query the installation path of the software SQL Server 2000? View 2,219 Replies 21
Original Poster Posted 2008-09-23 19:52 ·  中国 江西 南昌 电信
初级用户
Credits 38
Posts 17
Joined 2008-04-10 15:23
18-year member
UID 115485
Gender Male
Status Offline
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 ]
Floor 2 Posted 2008-09-23 20:44 ·  中国 江西 南昌 电信
初级用户
Credits 38
Posts 17
Joined 2008-04-10 15:23
18-year member
UID 115485
Gender Male
Status Offline
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)
Floor 3 Posted 2008-09-23 20:49 ·  美国 惠普HP
版主
★★★★★
Credits 9,023
Posts 5,017
Joined 2007-05-31 19:39
19-year member
UID 89899
Gender Male
Status Offline
```@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%
```
Floor 4 Posted 2008-09-23 20:58 ·  中国 江西 南昌 电信
初级用户
Credits 38
Posts 17
Joined 2008-04-10 15:23
18-year member
UID 115485
Gender Male
Status Offline
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.
Floor 5 Posted 2008-09-24 03:43 ·  中国 广东 广州 天河区 电信
金牌会员
★★★★
一叶枝头,万树皆春
Credits 2,564
Posts 1,127
Joined 2006-12-25 22:57
19-year member
UID 74552
Gender Male
Status Offline
Please check that the installation path should be in the local variable path
49206C6F766520796F752067757973 54656C3A3133383238343036373837
Floor 6 Posted 2008-09-24 09:35 ·  中国 江西 南昌 电信
初级用户
Credits 38
Posts 17
Joined 2008-04-10 15:23
18-year member
UID 115485
Gender Male
Status Offline
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
Floor 7 Posted 2008-09-24 09:38 ·  中国 江西 南昌 电信
初级用户
Credits 38
Posts 17
Joined 2008-04-10 15:23
18-year member
UID 115485
Gender Male
Status Offline
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 ]
Floor 8 Posted 2008-09-24 09:44 ·  美国 惠普HP
版主
★★★★★
Credits 9,023
Posts 5,017
Joined 2007-05-31 19:39
19-year member
UID 89899
Gender Male
Status Offline
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?
Floor 9 Posted 2008-09-24 09:56 ·  中国 江西 南昌 电信
初级用户
Credits 38
Posts 17
Joined 2008-04-10 15:23
18-year member
UID 115485
Gender Male
Status Offline
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.
Floor 10 Posted 2008-09-24 10:13 ·  美国 惠普HP
版主
★★★★★
Credits 9,023
Posts 5,017
Joined 2007-05-31 19:39
19-year member
UID 89899
Gender Male
Status Offline
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
Floor 11 Posted 2008-09-24 10:30 ·  中国 江西 南昌 电信
初级用户
Credits 38
Posts 17
Joined 2008-04-10 15:23
18-year member
UID 115485
Gender Male
Status Offline
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?
Floor 12 Posted 2008-09-24 10:41 ·  中国 江西 南昌 电信
初级用户
Credits 38
Posts 17
Joined 2008-04-10 15:23
18-year member
UID 115485
Gender Male
Status Offline
The `/nologo` option for `cscript` is used to suppress the Microsoft Visual Basic Script host logo from being displayed when the script is run.
Floor 13 Posted 2008-09-24 11:16 ·  美国 惠普HP
版主
★★★★★
Credits 9,023
Posts 5,017
Joined 2007-05-31 19:39
19-year member
UID 89899
Gender Male
Status Offline
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 /?
Floor 14 Posted 2008-09-24 12:07 ·  中国 江西 南昌 电信
初级用户
Credits 38
Posts 17
Joined 2008-04-10 15:23
18-year member
UID 115485
Gender Male
Status Offline
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 ]
Floor 15 Posted 2008-09-24 13:37 ·  美国 惠普HP
版主
★★★★★
Credits 9,023
Posts 5,017
Joined 2007-05-31 19:39
19-year member
UID 89899
Gender Male
Status Offline
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%"
Forum Jump: