-1

Trying to create a VBScript to open one of two different functions depending on the computer name. Here is my code:

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

However when I run it it gives me the error:

Varialble is undefined: 'objSysInfo'

Any solutions?

1

1 Answer 1

0

Option Explicit forces you to define all variables you use.

So add Dim objSysInfo above Set objSysInfo = CreateObject("WinNTSystemInfo").

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.