+ Post New Thread
Page 1 of 2 12 LastLast
Results 1 to 15 of 30
Scripts Thread, Limit Logon VBS Version in Coding and Web Development; Ok I have written the VBS versions of the scripts by Murat Yildirimoglu as posted by Russdev in this post. ...
  1. #1
    ChrisH's Avatar
    Join Date
    Jun 2005
    Location
    East Lancs
    Posts
    4,995
    Thank Post
    123
    Thanked 286 Times in 263 Posts
    Rep Power
    108

    Limit Logon VBS Version

    Ok I have written the VBS versions of the scripts by Murat Yildirimoglu as posted by Russdev in this post.

    Use at your own risk I have only tested them at home. You need to set the server and share at the top. The users must have change permission on the share.
    If you just want to test without getting logged off then
    Change this line:

    Code:
    WshShell.Run "logoff"
    To

    Code:
     'WshShell.Run "logoff"
    and uncomment these lines

    Code:
    'Wscript.Echo "The user is already logged on"
    Else
    'Wscript.Echo "The user is not logged on"
    So they read

    Code:
    Wscript.Echo "The user is already logged on"
    Else
    Wscript.Echo "The user is not logged on"
    I can think of a few improvements I can make to this and will do them at a later date
    Full listing here and a rar file with both in

    Code:
    '*************************************************************************
    '*                                                                                                                   *
    '* Limit login script (Login Part)                                       *
    '* Version 0.1 by  29/07/2005             *
    '* This is a VBS version of a script written by Murat Yildirimoglu       *
    '* USE THIS SCRIPT AT YOUR OWN RISK				         *
    '* I TAKE NO RESPONSIBILTY FOR ANYTHING COULD HAPPEN AS A RESULT         *
    '* OF RUNNING THIS SCRIPT                                                *
    '* 									 *
    '*************************************************************************
    
    'Begin Constant Declaration
    Const Server_Name = "megacity1" 'The server the shared directory will sit on
    Const Share_Name = "logon$"     ' The share name
    
    Const ForReading = 1
    Const ForAppending = 8
    
    ' Begin Variable declaration
    
    Set WshShell = WScript.CreateObject("WScript.Shell")
    Set WshNetwork = WScript.CreateObject("WScript.Network")
    Set ObjFSO = CreateObject("Scripting.FileSystemObject")
    
    Dim StrUserName ' Current user
    Dim StrStrMachineName
    Dim StrStrPathName
    Dim StrStrMachineFile
    Dim StrStrUserFile
    
    
    '************************* Main Code *************************
    'On Error Resume Next
    
    StrUserName = ""
    ' Wait until the user is really logged in...
    While StrUserName = ""
    	WScript.Sleep 100 ' 1/10 th of a second
    	StrUserName = WSHNetwork.UserName ' Get the user name
    Wend
    StrMachineName = WshNetwork.ComputerName 'Get the machine Name
    
    StrPathName = "\\" & Server_Name & "\" & Share_Name & "\" 
    
    If ObjFSO.FileExists (StrPathName & StrUserName & ".txt") Then
    WshShell.Run "logoff"
    'Wscript.Echo "The user is already logged on"
    Else
    'Wscript.Echo "The user is not logged on"
    Set StrUserFile = ObjFSO.CreateTextFile(StrPathName & StrUserName & ".txt")
    StrUserFile.WriteLine StrUserName & " " & "has logged onto" & " " & StrMachineName
    StrUserFile.Close
    Set StrMachineFile = ObjFSO.CreateTextFile(StrPathName & StrMachineName & ".txt")
    StrMachineFile.WriteLine StrUserName & " " & "has logged onto" & " " & StrMachineName
    StrMachineFile.Close
    End If
    Code:
    '*************************************************************************
    '*                                                                       *
    '* Limit login script (Logoff Part)                                      *
    '* Version 0.1  29/07/2005             *
    '* This is a VBS version of a script written by Murat Yildirimoglu       *
    '* USE THIS SCRIPT AT YOUR OWN RISK				         *
    '* I TAKE NO RESPONSIBILTY FOR ANYTHING COULD HAPPEN AS A RESULT         *
    '* OF RUNNING THIS SCRIPT                                                *
    '* 									 *
    '*************************************************************************
    
    'Begin Constant Declaration
    Const Server_Name = "megacity1" 'The server the shared directory will sit on
    Const Share_Name = "logon$"     ' The share name
    
    
    ' Begin Variable declaration
    
    Set WshShell = WScript.CreateObject("WScript.Shell")
    Set WshNetwork = WScript.CreateObject("WScript.Network")
    Set ObjFSO = CreateObject("Scripting.FileSystemObject")
    
    Dim StrUserName ' Current user
    Dim StrMachineFile 
    Dim StrPathName
    
    
    
    '************************* Main Code *************************
    On Error Resume Next
    StrUserName = WSHNetwork.UserName ' Get the user name
    StrMachineName = WshNetwork.ComputerName 'Get the machine Name
    StrPathName = "\\" & Server_Name & "\" & Share_Name & "\" 
    
    If ObjFSO.FileExists (StrPathName & StrUserName & ".txt") Then 'Delete the files if they exist
    ObjFSO.DeleteFile (StrPathName & StrUserName & ".txt")
    ObjFSO.DeleteFile (StrPathName & StrMachineName & ".txt")
    End If
    Attached Files Attached Files
    Last edited by ChrisH; 12th March 2014 at 09:04 PM.

  2. #2

    russdev's Avatar
    Join Date
    Jun 2005
    Location
    Leicestershire
    Posts
    6,958
    Thank Post
    735
    Thanked 553 Times in 368 Posts
    Blog Entries
    3
    Rep Power
    205

    Re: Limit Logon VBS Version

    great...

    will try when get back in to work in a week...

    if you ran msgbox and than ran the logoff does the script hold at msgbox until clicked ok..

    As thinking it would be best if it telss the user why it is logging off...

    Rus

  3. #3

    Ric_'s Avatar
    Join Date
    Jun 2005
    Location
    Boston, MA
    Posts
    7,597
    Thank Post
    109
    Thanked 770 Times in 598 Posts
    Rep Power
    183

    Re: Limit Logon VBS Version

    Quote Originally Posted by russdev
    if you ran msgbox and than ran the logoff does the script hold at msgbox until clicked ok..

    As thinking it would be best if it telss the user why it is logging off...

    Rus
    It's always more fun to do it without telling them

    Just a thought but if the text file that it writes contains the computer name of the logged on user, you could log that user off instead and allow the new user to log on - use something like pslogoff for this. If you are feeling generous, you could even tell the user why they are suddenly being forced to logoff and give them 30secs to save their work.

  4. #4

    russdev's Avatar
    Join Date
    Jun 2005
    Location
    Leicestershire
    Posts
    6,958
    Thank Post
    735
    Thanked 553 Times in 368 Posts
    Blog Entries
    3
    Rep Power
    205

    Re: Limit Logon VBS Version

    that's a good idea..

    But on that score would need to make sure script logged everything so can check back over logs to see why a user was logged off..

    russ

  5. #5

    Ric_'s Avatar
    Join Date
    Jun 2005
    Location
    Boston, MA
    Posts
    7,597
    Thank Post
    109
    Thanked 770 Times in 598 Posts
    Rep Power
    183

    Re: Limit Logon VBS Version

    @Russ: That goes without saying. Something along the lines of "<username> tried to log onto <computer name> whilst logged onto <computer name> - like that's going to happen! Fool!"?

  6. #6
    ChrisH's Avatar
    Join Date
    Jun 2005
    Location
    East Lancs
    Posts
    4,995
    Thank Post
    123
    Thanked 286 Times in 263 Posts
    Rep Power
    108

    Re: Limit Logon VBS Version

    Some of these things I have already thought about doing as an update. For this version though I just wanted to copy the batch version as close as possible then add from there.
    If we get a good list together I'm sure between us we can get it how we want it.
    I'm just getting my head round database access from VBS at the mo. I have had to read the same 4 pages 3 times so far :P

  7. #7
    ChrisH's Avatar
    Join Date
    Jun 2005
    Location
    East Lancs
    Posts
    4,995
    Thank Post
    123
    Thanked 286 Times in 263 Posts
    Rep Power
    108

    Re: Limit Logon VBS Version

    Looking at this all now I think this can be all done into a database. I'm thinking a MYSQL database that can hold 2 tables. One with the history of logons and one that holds current logons. Also then query the history through ASP, which is something somebody else has already implemented and posted about.

    Any thoughts?

    Course I want to do a HTA for my user import script first :P

  8. #8
    ChrisH's Avatar
    Join Date
    Jun 2005
    Location
    East Lancs
    Posts
    4,995
    Thank Post
    123
    Thanked 286 Times in 263 Posts
    Rep Power
    108

    Re: Limit Logon VBS Version

    Anyone currently using this and would like to provide any feedback? I am still working of the database version as every time I start coding it I seem to get dragged of to do something else :?

  9. #9

    russdev's Avatar
    Join Date
    Jun 2005
    Location
    Leicestershire
    Posts
    6,958
    Thank Post
    735
    Thanked 553 Times in 368 Posts
    Blog Entries
    3
    Rep Power
    205

    Re: Limit Logon VBS Version

    start testing it but had problesm but not down to script but down to getting rm to run accept scripts and not error out goiong to look at it next week if get time.

    russ

  10. #10

    Join Date
    Mar 2006
    Location
    Rainham, Essex.
    Posts
    5
    Thank Post
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    Re: Limit Logon VBS Version

    I have been working on a version of the script that logs access, prompts the user to ask which machine they wish to log out from, and also works with RM CC3.
    I have been using it for the past month or so, and it is working well.
    Attached Files Attached Files

  11. #11
    ChrisH's Avatar
    Join Date
    Jun 2005
    Location
    East Lancs
    Posts
    4,995
    Thank Post
    123
    Thanked 286 Times in 263 Posts
    Rep Power
    108

    Re: Limit Logon VBS Version

    Just had a quick scan and that looks very good One day im going to have to sit down and start finishing of all the half done projects I have started

    I dont seem to get the time anymore to sit down for any period of time and bash out code :?

  12. #12
    apeo's Avatar
    Join Date
    Sep 2005
    Location
    Lost
    Posts
    1,612
    Thank Post
    95
    Thanked 115 Times in 111 Posts
    Rep Power
    42

    Re: Limit Logon VBS Version

    Looks interesting.

  13. #13
    Snuffkins's Avatar
    Join Date
    Jan 2006
    Posts
    206
    Thank Post
    14
    Thanked 8 Times in 8 Posts
    Rep Power
    22

    Re: Limit Logon VBS Version

    Just started having a little test of it and it works a treat... Wonder if there's anyway of forcing them to click yes or no and not be able to do anything else till they have???

    Cause with the kids here i know they'll just ignore it and work around it .

  14. #14

    plexer's Avatar
    Join Date
    Dec 2005
    Location
    Norfolk
    Posts
    13,614
    Thank Post
    746
    Thanked 1,707 Times in 1,520 Posts
    Rep Power
    437

    Re: Limit Logon VBS Version

    Looks very good I developed a vbs to do this a while ago and never thought about sticking it up as I haven't actively used it for a while.

    My version would sometimes not clear up after a user logged off so then it wouldn't let them logon from anywhere

    Ben

  15. #15
    ChrisH's Avatar
    Join Date
    Jun 2005
    Location
    East Lancs
    Posts
    4,995
    Thank Post
    123
    Thanked 286 Times in 263 Posts
    Rep Power
    108

    Re: Limit Logon VBS Version

    The only thing that does concern me though is the username and password in the script. Im sure something else could be done to make that a little more secure though.



SHARE:
+ Post New Thread
Page 1 of 2 12 LastLast

Similar Threads

  1. Printer limit
    By pedster666 in forum Hardware
    Replies: 10
    Last Post: 5th December 2007, 01:35 PM
  2. Limit Logon Woes..
    By Gatt in forum Windows
    Replies: 1
    Last Post: 6th November 2007, 01:55 PM
  3. Limit Login
    By faza in forum How do you do....it?
    Replies: 7
    Last Post: 19th July 2007, 04:48 PM
  4. Terminal Server - limit which computers can be used to logon
    By broc in forum Thin Client and Virtual Machines
    Replies: 5
    Last Post: 26th June 2007, 03:21 PM
  5. limit login
    By whatwherewhen in forum Network and Classroom Management
    Replies: 12
    Last Post: 20th February 2007, 07:29 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •