中国DOS联盟

-- 联合DOS 推动DOS 发展DOS --

联盟域名:www.cn-dos.net 论坛域名:www.cn-dos.net/forum
DOS,代表着自由开放与发展,我们努力起来,学习FreeDOS和Linux的自由开放与GNU精神,共同创造和发展美好的自由与GNU GPL世界吧!

中国DOS联盟论坛
现在时间是 2026-06-26 14:34
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » 请教有关脚本程序变量内容传递问题 查看 1,601 回复 7
楼 主 请教有关脚本程序变量内容传递问题 发表于 2007-02-27 00:43 ·  中国 广东 深圳 电信
高级用户
★★★
积分 793
发帖 312
注册 2004-09-02 00:00
21年会员
UID 31104
性别 男
状态 离线
请教有关脚本程序变量内容传递问题

vbs脚本功能巨大,很多dos命令行不能完成或很复杂的工作,vbs轻而易举。

可惜自己对vbs一窍不通,现请教各位大大,如何将vbs的一个变量内容传递给dos bat文件使用
(可以由vbs创建一个winows公共变量,然后由dos bat文件读取,可是自己不懂vbs如何才能创建
这样一个公共变量)。

谢谢了。
2 发表于 2007-02-27 01:02 ·  中国 广东 深圳 电信
高级用户
★★★
积分 793
发帖 312
注册 2004-09-02 00:00
21年会员
UID 31104
性别 男
状态 离线
我是想得到正在运行的操作系统(名称或特征号),然后用bat(cmd)文件处理。

如果DOS直接可以读取,那就更好了。
3 发表于 2007-02-27 01:14 ·  中国 广东 广州 黄埔区 电信
金牌会员
★★★★
一叶枝头,万树皆春
积分 2,564
发帖 1,127
注册 2006-12-25 22:57
19年会员
UID 74552
性别 男
状态 离线
你说的在CMD下好像都可以最简单的是VER命令,要详细内容可能通过WMIC获取
4 发表于 2007-02-27 02:09 ·  中国 湖北 武汉 电信
版主
★★★★★
积分 11,386
发帖 4,938
注册 2006-07-23 17:10
19年会员
UID 59080
状态 离线
wmic os get name,serialnumber
5 发表于 2007-02-27 05:50 ·  中国 广东 深圳 龙岗区 电信
高级用户
★★★
积分 793
发帖 312
注册 2004-09-02 00:00
21年会员
UID 31104
性别 男
状态 离线
Originally posted by everest79 at 2007-2-27 01:14 AM:
你说的在CMD下好像都可以最简单的是VER命令,要详细内容可能通过WMIC获取


但是ver命令似乎不能分别系统的版本(如XP是HOME还是PROFESSIONAL)。
6 发表于 2007-02-27 06:24 ·  中国 广东 电信
荣誉版主
★★★★
batch fan
积分 5,226
发帖 1,737
注册 2006-03-10 00:38
20年会员
UID 51697
来自 成都
状态 离线
  systeminfo 命令跑出来的信息非常详细,应该可以满足你的要求。
尺有所短,寸有所长,学好CMD没商量。
考虑问题复杂化,解决问题简洁化。
7 发表于 2007-02-27 12:28 ·  中国 广东 深圳 龙岗区 电信
高级用户
★★★
积分 793
发帖 312
注册 2004-09-02 00:00
21年会员
UID 31104
性别 男
状态 离线
痛苦。好不容易才弄好。

现把批处理程序贴出,请各位大大指正。

程序功能为确定正在运行的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
8 发表于 2007-02-27 13:03 ·  中国 广东 深圳 龙岗区 电信
高级用户
★★★
积分 793
发帖 312
注册 2004-09-02 00:00
21年会员
UID 31104
性别 男
状态 离线
上面程序走了大弯路了。修改如下:
程序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
论坛跳转: