![]() |
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-09 21:51 |
47,811 topics / 349,897 posts / today 2 new / 48,255 members |
| DOS批处理 & 脚本技术(批处理室) » How to query the installation path of the software SQL Server 2000? |
| Printable Version 2,225 / 21 |
| Floor1 augvii | Posted 2008-09-23 19:52 |
| 初级用户 Posts 17 Credits 38 | |
|
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 ] |
|
| Floor2 augvii | Posted 2008-09-23 20:44 |
| 初级用户 Posts 17 Credits 38 | |
|
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)
|
|
| Floor3 HAT | Posted 2008-09-23 20:49 |
| 版主 Posts 5,017 Credits 9,023 | |
|
```@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% ``` |
|
| Floor4 augvii | Posted 2008-09-23 20:58 |
| 初级用户 Posts 17 Credits 38 | |
|
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. |
|
| Floor5 everest79 | Posted 2008-09-24 03:43 |
| 金牌会员 Posts 1,127 Credits 2,564 | |
|
Please check that the installation path should be in the local variable path
|
|
| Floor6 augvii | Posted 2008-09-24 09:35 |
| 初级用户 Posts 17 Credits 38 | |
|
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
|
|
| Floor7 augvii | Posted 2008-09-24 09:38 |
| 初级用户 Posts 17 Credits 38 | |
|
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 ] |
|
| Floor8 HAT | Posted 2008-09-24 09:44 |
| 版主 Posts 5,017 Credits 9,023 | |
|
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? |
|
| Floor9 augvii | Posted 2008-09-24 09:56 |
| 初级用户 Posts 17 Credits 38 | |
|
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. |
|
| Floor10 HAT | Posted 2008-09-24 10:13 |
| 版主 Posts 5,017 Credits 9,023 | |
|
What is the version of the machine with the problem?
Run this code on that machine and post the result: Should the code for calling VBS be like this: |
|
| Floor11 augvii | Posted 2008-09-24 10:30 |
| 初级用户 Posts 17 Credits 38 | |
|
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? |
|
| Floor12 augvii | Posted 2008-09-24 10:41 |
| 初级用户 Posts 17 Credits 38 | |
|
The `/nologo` option for `cscript` is used to suppress the Microsoft Visual Basic Script host logo from being displayed when the script is run.
|
|
| Floor13 HAT | Posted 2008-09-24 11:16 |
| 版主 Posts 5,017 Credits 9,023 | |
|
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 /? |
|
| Floor14 augvii | Posted 2008-09-24 12:07 |
| 初级用户 Posts 17 Credits 38 | |
|
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 ] |
|
| Floor15 HAT | Posted 2008-09-24 13:37 |
| 版主 Posts 5,017 Credits 9,023 | |
|
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: |
|
| 1 2 Next |
|
[ Contact the Union admin team -
中国DOS联盟 -
Standard version ] Sponsored by ifanr Inc | © 2001–2023 |