Help with VB script request
Posted on 2005-03-04
I am the network admin for a High School and am trying to disallow the students from logging on to more than one computer at a time. I am not concerned about how many computers a staff of faculty member signs into.
Currently I have a script using NTNAME.exe to detect if a user is currently logged in and if so, kick them off. Problem with this is it kicks everyone off.
Set WshShell =WScript.CreateObject("WScript.Shell")
Set WshEnvir =WshShell.Environment("Process")
Set WshNetwork =WScript.CreateObject("WScript.Network")
'check to see if user is logged in to another computer log file is created in temp folder on c
If WshShell.Run("\\hwohd01\scripts\login\ntname.exe %username% >>C:\otherpc.txt", 1, true) = 1 Then
'username has been found, proceeding to warn and kick the user off
intpopup = WshShell.Popup("You are trying to log into more than one workstation. Please make certain that you log off of ALL workstations before using this workstation.",5,"Warning: Multiple Log On Detected!",48)
'logout exe is declared here
'our job is done
'user has not been found, exit vbs and continue with login
Because we've setup the user IDs for Student to start with a number (0-9) and the facutly starts with a letter (first letter of their last name), this should be an easy fix, however.. I'm not good in VBS and need some help.
What I think I should be able to do is add an if left$(%username%, 1) = 0 through 9, continue with script else end. I just don't know what the code should look like in VB or where it should be entered in the script.
Help is appreciated.