Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Stop Multiple Windows Logins

 
Logged in as: Guest
arrSession:exec spGetSession 2,16,26001
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> Post a VBScript >> Stop Multiple Windows Logins
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 Stop Multiple Windows Logins - 9/15/2005 3:48:22 PM   
  amfony

 

Posts: 6
Score: 0
Joined: 9/11/2005
Status: offline
'"Multiple Logons a problem? Not anymore!!" - By Amfony
'
'This is my vbscript interpretation of a batch script that will stop multiple logons in a windows environment (with logon and logoff scripts)
'
'
'Requirements for script to work:
'
'A server with a shared folder named "logons" everyone full access (for easiness of implementation)
'A Folder within the share folder "logons" named "SecondAttempt"
'A XL file named "duplicates.xls" with lines of DATA (being Anything) in the 4th and 5th row (Because ammending XL is a biiiiyatch)
'A XL file named "Status.xls" with 2 lines of DATA (being Anything) in the 4th and 5th row (refer above)
'
'These XL files need to be on the \\server\logons share
'
'
'Pseudo Code
'
'The idea of this code is to have a user when logging on create a file/folder object based on their username on a share folder on a server. Then incorporate in the script an IF EXists
'statement to forecfully log the user off if there is already a file/folder object with that same Username name.
'
'My code however will record to XL files everytime a user logs on successfully (write to status.xls), or unsuccessfully (write to duplicates.xls), also in addition to the username,
'computername, time and date at that the event occured. My code will also write the event time details INSIDE the file it created based on username, which it will then read from
'to display a popup box with variables about the user,computer loggedinto and so forth if there is a secondlogon attempt.
'
'My script will upon second logon, create a second text file named "\\SERVER\logons\secondAttempt\second%username%.txt" that it will then incorporate into my
'logoff.vbs script (REFER BELOW)


'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~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txt" EXIST (which inturn means that there was a concurrent connection, a multiple logon was attempted, and that
'this logoff procedure is forced {not by choice}
'
'THEN delete the "\\SERVER\logons\secondattempt\second%username%.txt" File (clean up duty)
'and then proceed to send.keys "logoff.exe" to the shell.
'
'
'IF However the " \\... second%username%.txt DOES NOT EXIST
'THEN
'
'Call gracefulexit function which will delete the "\\SERVER\logons\%username%.txt file. (Leaving the user free to log on again anywhere/time they wish.)
'
'

Dim strUsername, del, secondattemptFile, file
Set fso = CreateObject("Scripting.FileSystemObject")
Set net = createobject("Wscript.network")
Set wshell = CreateObject("wscript.Shell")

strUserName = net.username
file = ("\\thomas2k\logons\" & strUsername & ".txt")
secondAttemptFile = ("\\thomas2k\logons\SecondAttempt\" & "Second" & strUserName & ".txt")
If fso.fileexists(secondAttemptFile) then
SecondAttemptExit(secondAttemptFile)
Else
GracefulExit(file)

End If
'----------------------------------------------------------
Function SecondAttemptExit(SecondAttemptDel)
FSO.deletefile(SecondAttemptDel)
wshell.run "logoff.exe"
End Function
Function GracefulExit(GracefulDel)
fso.deletefile(GracefulDel)
wshell.run "logoff.exe"
End Function

< Message edited by Snipah -- 9/16/2005 6:20:15 AM >
 
 
Post #: 1
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> Post a VBScript >> Stop Multiple Windows Logins Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts