?
Solved

Help with VB script request

Posted on 2005-03-04
3
Medium Priority
?
394 Views
Last Modified: 2008-01-09
Folks-
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
Dim intpopup

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
WshShell.Run "\\hwohd01\scripts\login\logout.exe"

'our job is done
WScript.Quit

Else
'user has not been found, exit vbs and continue with login

End If

WScript.Quit

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.
Steve
0
Comment
Question by:scporter
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 8

Accepted Solution

by:
fatalXception earned 1000 total points
ID: 13470113
Once you have your hands on the username in a variable in the script, this would do it:

firstDigit = mid(username,1,1)
if instr(1,"0123456789",firstDigit) <>0 then
     'it is a student, continue
else
     'it is faculty member, end
end if
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Having just graduated from college and entered the workforce, I don’t find myself always using the tools and programs I grew accustomed to over the past four years. However, there is one program I continually find myself reverting back to…R.   So …
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
This video teaches viewers about errors in exception handling.
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question