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:
ToCode:WshShell.Run "logoff"
and uncomment these linesCode:'WshShell.Run "logoff"
So they readCode:'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 dateCode:Wscript.Echo "The user is already logged on" Else Wscript.Echo "The user is not logged on"
Full listing here and a rar file with both in
Code:'************************************************************************* '* * '* Limit login script (Login Part) * '* Version 0.1 by Chris Hindmarch Fishermore High 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 IfCode:'************************************************************************* '* * '* Limit login script (Logoff Part) * '* Version 0.1 by Chris Hindmarch Fishermore High 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



LinkBack URL
About LinkBacks
Reply With Quote






One day im going to have to sit down and start finishing of all the half done projects I have started
. 
