VBS 脚本根据计算机名称打开某些应用程序
VBS Script To Open Certain Applications Depending on Computer Name
正在尝试创建 VBScript 以根据计算机名称打开两个不同功能之一。
这是我的代码:
Option Explicit
Dim objShell
Set objShell = CreateObject("WScript.Shell")
Set objSysInfo = CreateObject("WinNTSystemInfo")
strComputerName = objSysInfo.ComputerName
Sub MIS()
objShell.Run "firefox"
objShell.Run "P:\Private"
objShell.Run ("""C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_86\pythonw.exe""")
objShell.Run ("""C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_86\Lib\idlelib\idle.pyw""")
End Sub
Sub Norm()
objShell.Run "firefox"
objShell.Run "P:\Private"
End Sub
If strComputerName = "BDREDCTR175-74" Then
MIS()
Else
Norm()
End If
但是当我 运行 它给了我错误:
有什么解决办法吗?
Option Explicit
强制您定义您使用的所有变量。
所以在Set objSysInfo = CreateObject("WinNTSystemInfo")
上面加上Dim objSysInfo
。
正在尝试创建 VBScript 以根据计算机名称打开两个不同功能之一。 这是我的代码:
Option Explicit
Dim objShell
Set objShell = CreateObject("WScript.Shell")
Set objSysInfo = CreateObject("WinNTSystemInfo")
strComputerName = objSysInfo.ComputerName
Sub MIS()
objShell.Run "firefox"
objShell.Run "P:\Private"
objShell.Run ("""C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_86\pythonw.exe""")
objShell.Run ("""C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_86\Lib\idlelib\idle.pyw""")
End Sub
Sub Norm()
objShell.Run "firefox"
objShell.Run "P:\Private"
End Sub
If strComputerName = "BDREDCTR175-74" Then
MIS()
Else
Norm()
End If
但是当我 运行 它给了我错误:
有什么解决办法吗?
Option Explicit
强制您定义您使用的所有变量。
所以在Set objSysInfo = CreateObject("WinNTSystemInfo")
上面加上Dim objSysInfo
。