yinbinly 发表于 2013-1-20 11:56:25

【已解决】不会声明变量

本帖最后由 yinbinly 于 2013-1-20 12:55 编辑

Opt("MustDeclareVars", 1)
Opt("TrayAutoPause",0)
If @OSVersion = "WIN_X0P" Then
        MsgBox(64, "提示", "XP系统无法修改开机画面!", 2)
        Exit
EndIf
Traytip(" 温馨提示","正在检测机器型号" & @CRLF & "以确定电脑品牌,请勿动键盘鼠标",15,4)
Sleep(1200)
Global $info
$strComputer = "."
$objWMIService = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\" & $strComputer & "\root\cimv2")

$xh = ''
$colChassis = $objWMIService.ExecQuery ("Select * from Win32_SystemEnclosure")

$computerModel = $objWMIService.ExecQuery("Select * from Win32_ComputerSystemProduct")
For $objItem in $computerModel
      $computerModel2 = $objItem.vendor & $objItem.name & "(" & $objItem.IdentifyingNumber & ")"
Next
$info&=""&$computerModel2
郁闷了就 不加那个OPT 有些机器不会报错 有些会报

虫子樱桃 发表于 2013-1-20 12:02:44



额,小修改
Opt("MustDeclareVars", 1)
Opt("TrayAutoPause",0)
If @OSVersion = "WIN_X0P" Then
      MsgBox(64, "提示", "XP系统无法修改开机画面!", 2)
      Exit
EndIf
Traytip(" 温馨提示","正在检测机器型号" & @CRLF & "以确定电脑品牌,请勿动键盘鼠标",15,4)
Sleep(1200)
Global $info,$strComputer,$objWMIService,$xh,$colChassis,$computerModel,$computerModel2
$strComputer = "."
$objWMIService = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\" & $strComputer & "\root\cimv2")

$xh = ''
$colChassis = $objWMIService.ExecQuery ("Select * from Win32_SystemEnclosure")

$computerModel = $objWMIService.ExecQuery("Select * from Win32_ComputerSystemProduct")
For $objItem in $computerModel
      $computerModel2 = $objItem.vendor & $objItem.name & "(" & $objItem.IdentifyingNumber & ")"
Next
$info&=""&$computerModel2
MsgBox(0,'','型号!'&$info)

haijie1223 发表于 2013-1-20 12:44:21

那个opt是强制必须声明变量啊

yinbinly 发表于 2013-1-20 12:55:00

回复 3# haijie1223


    是啊,发哥 如果改成0的话 是这样 有些机器不报错,有些报错

haijie1223 发表于 2013-1-20 13:59:27

回复 4# yinbinly


    那就全部定义一下,先声明变量是不会出错的。

yinbinly 发表于 2013-1-20 20:11:28

回复 2# 虫子樱桃
#Region ;**** 参数创建于 ACNWrapper_GUI ****
#PRE_Icon=iMac On.ico
#PRE_Res_Comment=清理优化WIN7 XP程序
#PRE_Res_Description=yinbinly
#PRE_Res_Fileversion=1.0.1.2
#PRE_Res_Fileversion_AutoIncrement=p
#PRE_Res_LegalCopyright=鼎盛商贸 Corporation 2008-2012
#PRE_Res_requestedExecutionLevel=None
#EndRegion ;**** 参数创建于 ACNWrapper_GUI ****
Opt("MustDeclareVars", 1)
Opt("TrayAutoPause",0)
If @OSVersion = "WIN_XP" Then
      MsgBox(64, "提示", "XP系统无法修改开机画面!", 2)
      Exit
EndIf
Traytip(" 温馨提示","正在检测机器型号" & @CRLF & "以确定电脑品牌,请勿动键盘鼠标",15,4)
Sleep(1200)
Global $info,$strComputer,$objWMIService,$xh,$colChassis,$computerModel,$computerModel2
$strComputer = "."
$objWMIService = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\" & $strComputer & "\root\cimv2")

$xh = ''
$colChassis = $objWMIService.ExecQuery ("Select * from Win32_SystemEnclosure")

$computerModel = $objWMIService.ExecQuery("Select * from Win32_ComputerSystemProduct")
For $objItem in $computerModel
      $computerModel2 = $objItem.vendor & $objItem.name & "(" & $objItem.IdentifyingNumber & ")"
Next
$info&=""&$computerModel2
;MsgBox(0,'','型号!'&$info)


Select
        Case StringInStr($info, 'lenovo')
        TrayTip("检测完成!", "这是联想", 5, 1)
        If @OSVersion = "WIN_7" Then
        FileCopy(@ScriptDir & "\File\lenovo.jpg", @WindowsDir & "\System32\oobe\info\Backgrounds\backgroundDefault.jpg", 9)
        RegWrite("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\LogonUI\Background", "OEMBackground", "REG_DWORD", "1")
    EndIf
    Case StringInStr($info, 'dell')
        TrayTip("检测完成!", "这是戴尔", 5, 1)
    If @OSVersion = "WIN_7"Then
        FileCopy(@ScriptDir & "\File\dell.jpg",@SystemDir & "\oobe\info\Backgrounds\backgroundDefault.jpg",9)
        RegWrite("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\LogonUI\Background", "OEMBackground", "REG_DWORD", "1")
    EndIf
   Case StringInStr($info, 'asus')
        TrayTip("检测完成!", "这是华硕", 5, 1)
    If @OSVersion = "WIN_7"Then
        FileCopy(@ScriptDir & "\File\asus.jpg",@SystemDir & "\oobe\info\Backgrounds\backgroundDefault.jpg",9)
        RegWrite("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\LogonUI\Background", "OEMBackground", "REG_DWORD", "1")
    EndIf

        Case Else

                MsgBox(0, '提示:', '未知品牌',1)


EndSelect
Sleep(1800)

加上下面的代码又报错!难道冲突?

hzxymkb 发表于 2013-1-20 22:21:06

回复 5# haijie1223


    发哥的技术越来越厉害了!
页: [1]
查看完整版本: 【已解决】不会声明变量