Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Help with VB script request

Posted on 2005-03-04
3
Medium Priority
?
395 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
1 Comment
 
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

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Question has a verified solution.

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

There is an easy way, in .NET, to centralize the treatment of all unexpected errors. First of all, instead of launching the application directly in a Form, you need first to write a Sub called Main, in a module. Then, set the Startup Object to th…
If you haven’t already, I encourage you to read the first article (http://www.experts-exchange.com/articles/18680/An-Introduction-to-R-Programming-and-R-Studio.html) in my series to gain a basic foundation of R and R Studio.  You will also find the …
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Suggested Courses

580 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