通过脚本确定操作系统版本 [英] Determining OS version via Scripting

查看:217
本文介绍了通过脚本确定操作系统版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现在其他网站上这个剧本,但我不能让它的工作,我不知道批处理脚本那么好

I found this script on another site but I can not get it to work and I don't know batch scripting that well

Set objWshShell = WScript.CreateObject("WScript.Shell")

strOSVersion = objWshShell.RegRead("HKLM\Software\Microsoft\Windows NT\CurrentVersion\CurrentVersion")

If strOSVersion = "5.1" Then
    Debug.WriteLine("Windows XP")
    Rem Insert Windows XP Statements
ElseIf strOSVersion = "6.0" Then
    Debug.WriteLine("Windows Vista")
    Rem Insert Windows Vista Statements
ElseIf strOSVersion = "6.1" Then
    Debug.WriteLine("Windows 7")
    Rem Insert Windows 7 Statements
End If

现在,如果我跑这我得到第二行的误差

now if I run this I get the error on the second line

'strOSVersion' is not recognized as an internal or external command
operable program or batch file.
= was unexpected at this time.

我不知道为什么。

I do not know why

推荐答案

这是一个VB脚本。您可以在一个名为像test.vbs文件保存

It's a VB script. You can save in a file named like test.vbs

然后打开命令提示符,将目录更改到您保存的文件。在提示符下键入 CSCRIPT test.vbs

Then open a command prompt, change directory to where you saved the file. At the prompt type cscript test.vbs.

这之前,我改变了的Debug.WriteLine 来电 WScript.Echo 代替。

Before that, I changed the Debug.WriteLine calls to WScript.Echo instead.

这篇关于通过脚本确定操作系统版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆