I required some VB which would run as a shutdown script and run some specific commands if the computer was not a laptop. Luckily this was simplified by the naming convention on our corporate network - all laptops have an L in the computer name. Here is one way this can be done - using a regular expression to find the number of L's in the computer name (and then take specific action if it is less than 1):
Option Explicit Dim objNTInfo, ComputerName, myRegExp, myMatches Set objNTInfo = CreateObject("WinNTSystemInfo") ComputerName = lcase(objNTInfo.ComputerName) 'Prepare a regular expression object Set myRegExp = New RegExp myRegExp.IgnoreCase = True myRegExp.Global = True myRegExp.Pattern = "l" Set myMatches = myRegExp.Execute(computerName) If myMatches.Count > 0 Then MsgBox ComputerName & " is a laptop" , vbInformation , "Results ... " else MsgBox ComputerName & " is not a laptop" , vbInformation , "Results ... " End If


0 Responses to “Identify computer type using VB Script”
Leave a Reply