之前我发的VBS程序还有一点小问题:如果CAD从来没有打开过加载应用程序的对话框,那么运行时就会发错。现我已改进了这个问题,使之作为“安装程序”更为适用。其内容如下: Dim WS, REG, Path, Key, SubKey, Value, el, flag Set WS = WScript.CreateObject("WScript.Shell") Path = WS.CurrentDirectory & "\Load.fas" Set REG = GetObject("winmgmts:\\.\root\default:StdRegProv") HKCU = &H80000001 HKLM = &H80000002 Key = "Software\Autodesk\AutoCAD" REG.GetStringValue HKCU, Key, "CurVer", Value Key = Key & "\" & Value REG.GetStringValue HKCU, Key, "CurVer", Value Key = Key & "\" & Value SubKey = "\Profiles" REG.GetStringValue HKCU, Key & SubKey, "", Value SubKey = SubKey & "\" & Value & "\Dialogs\Appload\Startup" REG.EnumValues HKCU, Key & SubKey, Item, Value If IsNull(Item) Then REG.CreateKey HKCU, Key & SubKey REG.SetStringValue HKCU, Key & SubKey, "", "1" REG.SetStringValue HKCU, Key & SubKey, "NumStartup", "1" REG.SetStringValue HKCU, Key & SubKey, "1Startup", Path SubKey = "\Applications\AcadAppload" REG.CreateKey HKCU, Key & SubKey REG.GetStringValue HKLM, Key & SubKey, "DESCRIPTION", Value REG.SetStringValue HKCU, Key & SubKey, "DESCRIPTION", Value REG.GetStringValue HKLM, Key & SubKey, "LOADER", Value REG.SetStringValue HKCU, Key & SubKey, "LOADER", Value REG.GetDWORDValue HKLM, Key & SubKey, "LOADCTRLS", Value Value = Value or 2 REG.SetDWORDValue HKCU, Key & SubKey, "LOADCTRLS", Value MsgBox "成功加入自动加载列表!" Else REG.GetStringValue HKCU, Key & SubKey, "", Value flag = False If Not IsNull(Value) Then Item = Value & "Startup" REG.GetStringValue HKCU, Key & SubKey, Item, Value If UCase(Right(Value,9))="\LOAD.FAS" Then flag = True End if IF flag Then MsgBox "TB Tools 已在自动加载列表中!" Else REG.GetStringValue HKCU, Key & SubKey, "NumStartup", Value Value = CStr(CInt(Value)+1) Item = Value & "Startup" REG.SetStringValue HKCU, Key & SubKey, "", Value REG.SetStringValue HKCU, Key & SubKey, "NumStartup", Value REG.SetStringValue HKCU, Key & SubKey, Item, Path SubKey = "\Applications\AcadAppload" REG.GetDWORDValue HKCU, Key & SubKey, "LOADCTRLS", Value Value = Value or 2 REG.SetDWORDValue HKCU, Key & SubKey, "LOADCTRLS", Value MsgBox "成功加入自动加载列表!" End if End if
|