标题: 请教有关脚本程序变量内容传递问题
[打印本页]
作者: willsion
时间: 2007-2-27 00:43
标题: 请教有关脚本程序变量内容传递问题
请教有关脚本程序变量内容传递问题
vbs脚本功能巨大,很多dos命令行不能完成或很复杂的工作,vbs轻而易举。
可惜自己对vbs一窍不通,现请教各位大大,如何将vbs的一个变量内容传递给dos bat文件使用
(可以由vbs创建一个winows公共变量,然后由dos bat文件读取,可是自己不懂vbs如何才能创建
这样一个公共变量)。
谢谢了。
作者: willsion
时间: 2007-2-27 01:02
我是想得到正在运行的操作系统(名称或特征号),然后用bat(cmd)文件处理。
如果DOS直接可以读取,那就更好了。
作者: everest79
时间: 2007-2-27 01:14
你说的在CMD下好像都可以最简单的是VER命令,要详细内容可能通过WMIC获取
作者: lxmxn
时间: 2007-2-27 02:09
wmic os get name,serialnumber
作者: willsion
时间: 2007-2-27 05:50
Quote: |
Originally posted by everest79 at 2007-2-27 01:14 AM:
你说的在CMD下好像都可以最简单的是VER命令,要详细内容可能通过WMIC获取 |
|
但是ver命令似乎不能分别系统的版本(如XP是HOME还是PROFESSIONAL)。
作者: namejm
时间: 2007-2-27 06:24
systeminfo 命令跑出来的信息非常详细,应该可以满足你的要求。
作者: willsion
时间: 2007-2-27 12:28
痛苦。好不容易才弄好。
现把批处理程序贴出,请各位大大指正。
程序功能为确定正在运行的Windows Vista版本。
程序1(直接读取注册表版本,速度快,不过由于注册表可能被修改,可能不准确)
@echo off
for /f "tokens=6,7" %%i in ('reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v ProductName^|find /i "ProductName"') do set os1=%%i && set os2=%%j
set VH="Home "
set VB="Business"
set VU="Ultimate"
set PR="Premium"
set BA="Basic"
if %os1% == %VH:~1,4% goto home
if %os1% == %VB:~1,8% goto business
if %os1% == %VU:~1,8% goto Ultimate
goto err
:home
if %os2% == %PR:~1,7% echo "This is Windows Vista Home Premium."
if %os2% == %BA:~1,5% echo "This is Windows Vista Home Basic."
goto end
:business
echo "This is Windows Vista Business."
goto end
:ultimate
echo "This is Windows Vista Ultimate."
goto end
:err
echo "Don't know this system."
:end
pause
程序2(通过systeminfo读取信息)
@echo off
for /f "tokens=6,7" %%i in ('systeminfo ^|find "OS 名称:"') do set os1=%%i && set os2=%%j
set VH="Home "
set VB="Business"
set VU="Ultimate"
set PR="Premium"
set BA="Basic"
if %os1% == %VH:~1,4% goto home
if %os1% == %VB:~1,8% goto business
if %os1% == %VU:~1,8% goto Ultimate
goto err
:home
if %os2% == %PR:~1,7% echo "This is Windows Vista Home Premium."
if %os2% == %BA:~1,5% echo "This is Windows Vista Home Basic."
goto end
:business
echo "This is Windows Vista Business."
goto end
:ultimate
echo "This is Windows Vista Ultimate."
goto end
:err
echo "Don't know this system."
:end
pause
作者: willsion
时间: 2007-2-27 13:03
上面程序走了大弯路了。修改如下:
程序1:
@echo off
for /f "tokens=6,7" %%i in ('reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v ProductName^|find /i "ProductName"') do set os1=%%i && set os2=%%j
if %os1% == Home goto home
if %os1% == Business goto business
if %os1% == Ultimate goto ultimate
goto err
:home
if %os2% == Premium echo "This is Windows Vista Home Premium."
if %os2% == Basic echo "This is Windows Vista Home Basic."
goto end
:business
echo "This is Windows Vista Business."
goto end
:ultimate
echo "This is Windows Vista Ultimate."
goto end
:err
echo "Don't know this system."
:end
pause
程序2:
@echo off
for /f "tokens=6,7" %%i in ('systeminfo ^|find "OS 名称:"') do set os1=%%i && set os2=%%j
if %os1% == Home goto home
if %os1% == Business goto business
if %os1% == Ultimate goto ultimate
goto err
:home
if %os2% == Premium echo "This is Windows Vista Home Premium."
if %os2% == Basic echo "This is Windows Vista Home Basic."
goto end
:business
echo "This is Windows Vista Business."
goto end
:ultimate
echo "This is Windows Vista Ultimate."
goto end
:err
echo "Don't know this system."
:end
pause