Amiga.org
The "Not Quite Amiga but still computer related category" => Alternative Operating Systems => Topic started by: adz on March 23, 2004, 02:36:37 AM
-
Hi all
Just wondering if any of you guys had come across a program (for Windows 2K/XP) that will, once the system is turned on, automatically log a user on at a specified time and then automatically log them off at a specified time to log another user on? And then at the end of the day automatically shut the machine down. I'm not even sure if something like this exists, but I have been asked to look into it. Any advice or clues would be greatly appreciated. Thanks in advance.
Adz
-
Stay clear of auto log on programs, i say...
Open to abuse, and best not to keep passwords on the machine...http://www.winguides.com/registry/display.php/13/ (http://www.winguides.com/registry/display.php/13/)
But windows scheduler will auto update and defrag etc....
As for auto shut-down try these programs...
http://www.tucows.com/shutdown95_default.html (http://www.tucows.com/shutdown95_default.html)
-
You can use TweakXP to Auto-Log on, just enter the details in there and it automatically changed the Registry so the machine logs on, you can manually edit the registry so the machine logs itself on, but I can't remember exactly how to.
-
Thanks guys, we currently use tweakui to log classroom workstations on already, we were hoping to have the lab machines set up to log on at a scheduled time for a particular class and then auto log off and log on for the next class. I've heard of it being done, but no one I know has tried it. Personally I think it will cause more headaches for me and my techs but when it comes from the top, you have to at least try.
-
Hello!
The logon information is here.
HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/WindowsNT/CurrentVersion/WinLogon
If you want the machine to log on, here should be the following string values:
AutoAdminLogon = 1
DefaultDomainName = Your domain name or the computer name
DefaultUserName = the username the computer will login with
DefaultPassword = the usernames password
Here follows a VBScript that can change these registry values. You have to change the domainname, username and password in the script, in the function SetAutoLogon.
If you change the SetAutoLogon function, so it accepts input parameters, you could use this script in the scheduling tasks in Windows XP.
=============================================================
Option Explicit
'******************************************************************
'* Constants
'******************************************************************
const KEY_QUERY_VALUE = &H0001
const KEY_SET_VALUE = &H0002
const KEY_CREATE_SUB_KEY = &H0004
const DELETE = &H00010000
Const HKEY_CLASSES_ROOT = &H80000000
Const HKEY_CURRENT_USER = &H80000001
Const HKEY_LOCAL_MACHINE = &H80000002
Const HKEY_USERS = &H80000003
Const JOIN_DOMAIN = 1
Const ACCT_CREATE = 2
Const ACCT_DELETE = 4
Const WIN9X_UPGRADE = 16
Const DOMAIN_JOIN_IF_JOINED = 32
Const JOIN_UNSECURE = 64
Const MACHINE_PASSWORD_PASSED = 128
Const DEFERRED_SPN_SET = 256
Const INSTALL_INVOCATION = 262144
'******************************************************************
'* Global Variables
'******************************************************************
Dim strReturnValue
Dim ReturnValue
Dim strDomain
Dim strUser
Dim strPassword
Dim objNetwork
Dim strComputer
Dim objComputer
'******************************************************************
' Wscript.Echo "The Begining"
'******************************************************************
'******************************************************************
'* Create A registry key
'******************************************************************
'Example of using the CreateARegistryKey and SetARegistryKey
strReturnValue = CreateARegistryKey("SOFTWARE\BBB\BB")
strReturnValue = SetARegistryKey("SOFTWARE\BBB\BB","Ready" ,"1")
If (strReturnValue <> "-1") Then
' Wscript.Echo "Ready Flag = " & strReturnValue
'******************************************************************
'* Script Code
'******************************************************************
' Wscript.Echo "The Script Begins" & vbTab & Now & vbNewLine
'******************************************************************
'Get the computer name. We need this for the reboot function.
Set objNetwork = CreateObject("WScript.Network")
strComputer = objNetwork.ComputerName
'Here we change the registry, to the right user that will be automatically
'logged in.
strReturnValue = SetAutoLogon
If (strReturnValue <> "-1") Then
' Wscript.Echo "Setting Atuologon successed"
Else
Wscript.Echo "Error Setting Autologon in the registry = " & strReturnValue
End If
'**********************************************************************
'* RebootComputer
'**********************************************************************
ReturnValue = RebootComputer(strComputer)
if ReturnValue <> 0 Then
Wscript.Quit -6
End If
'******************************************************************
' Wscript.Echo "The End"
'******************************************************************
'**********************************************************************
'* NAME: CreateARegistryKey
'* FUNCTION:
'**********************************************************************
Function CreateARegistryKey(strKeyPath)
Dim oReg
Dim sReturn
On Error Resume Next
Set oReg = GetObject("winmgmts://./root/default:StdRegProv")
sReturn = oReg.CreateKey(HKEY_LOCAL_MACHINE,strKeyPath)
Set oReg = Nothing
If Err <> 0 then
'* Wscript.Echo Err.Source & " " & Hex(Err) & ": " & Err.Description & "Error # " & CStr(Err.Number)
Err.Clear
CreateARegistryKey = "-1" 'Error
Else
CreateARegistryKey = "0" 'OK
End If
End Function
'**********************************************************************
'* NAME: SetARegistryKey
'* FUNCTION:
'**********************************************************************
Function SetARegistryKey(strKeyPath ,strKey ,strKeyValue)
Dim oReg
Dim sReturn
On Error Resume Next
Set oReg = GetObject("winmgmts://./root/default:StdRegProv")
sReturn = oReg.SetStringValue (HKEY_LOCAL_MACHINE,strKeyPath,strKey,strKeyValue)
Set oReg = Nothing
If Err <> 0 then
'* Wscript.Echo Err.Source & " " & Hex(Err) & ": " & Err.Description & "Error # " & CStr(Err.Number)
Err.Clear
SetARegistryKey = "-1" 'Error
Else
SetARegistryKey = "0"
End If
End Function
'**********************************************************************
'* NAME: GetARegistryKey
'* FUNCTION:
'**********************************************************************
Function GetARegistryKey(strKeyPath, strKey)
Dim oReg
Dim strKeyValue
Dim sReturn
On Error Resume Next
Set oReg = GetObject("winmgmts://./root/default:StdRegProv")
sReturn = oReg.GetStringValue (HKEY_LOCAL_MACHINE,strKeyPath,strKey,strKeyValue)
Set oReg = Nothing
If Err <> 0 then
'* Wscript.Echo Err.Source & " " & Hex(Err) & ": " & Err.Description & "Error # " & CStr(Err.Number)
Err.Clear
GetARegistryKey = "-1" 'Error
Else
GetARegistryKey = strKeyValue
End If
End Function
'**********************************************************************
'* NAME: RebootComputer
'* FUNCTION: Reboot Computer Need the Computer Name as input
'**********************************************************************
Function RebootComputer(sComputer)
Dim objWMIService
Dim colOperatingSystems
Dim objOperatingSystem
On Error Resume Next
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate,(Shutdown)}!\\" & sComputer & "\root\cimv2")
Set colOperatingSystems = objWMIService.ExecQuery ("Select * from Win32_OperatingSystem")
For Each objOperatingSystem in colOperatingSystems
ObjOperatingSystem.Reboot()
Next
Set colOperatingSystems = Nothing
Set objWMIService = Nothing
If Err = 0 then
RebootComputer = "0" 'OK
Else
Wscript.Echo Err.Source & " " & Hex(Err) & ": " & Err.Description & "Error # " & CStr(Err.Number)
Err.Clear
RebootComputer = "1" 'Error
End If
End Function
'**********************************************************************
'* NAME: SetAutoLogon
'* FUNCTION:
'**********************************************************************
Function SetAutoLogon()
strReturnValue = SetARegistryKey("SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon","AutoAdminLogon" ,"1")
If (strReturnValue <> "-1") Then
' Wscript.Echo "Ready Flag = " & strReturnValue
Else
Wscript.Echo "Error reading Ready Flag = " & strReturnValue
End If
strReturnValue = SetARegistryKey("SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon","DefaultDomainName" ,"DomainName")
If (strReturnValue <> "-1") Then
' Wscript.Echo "Ready Flag = " & strReturnValue
Else
Wscript.Echo "Error reading Ready Flag = " & strReturnValue
End If
strReturnValue = SetARegistryKey("SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon","DefaultUserName" ,"UserName")
If (strReturnValue <> "-1") Then
' Wscript.Echo "Ready Flag = " & strReturnValue
Else
Wscript.Echo "Error reading Ready Flag = " & strReturnValue
End If
strReturnValue = SetARegistryKey("SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon","DefaultPassword" ,"Password")
If (strReturnValue <> "-1") Then
' Wscript.Echo "Ready Flag = " & strReturnValue
Else
Wscript.Echo "Error reading Ready Flag = " & strReturnValue
End If
SetAutoLogon = strReturnValue
End Function
'******************************************************************
'*
'******************************************************************
==========================================================
Happy Coding and Good Luck!
/Jörgen Jönsson
-
I don't know if this is what you want or if its any good, but I noticed a piece of software called Roboform the other day. Available at download.com
Regards
-
@jonssonj
Where did you get that code from?? Do you have a link?? I was thinking about scripting the process and running it with task scheduler but, 1. I didn't really know where to start, and 2. trying to administer it using task scheduler would be a nightmare. You've given me a place to start but now I am trying to figure out a way to centrally manage it, ie. create a script that runs on a DC and issues logon/logoff commands to a group of computers in a particular OU, guess I'm gonna have to dust off my thinking cap. Thanks for all that, much appreciated.
-
@Cyberus
Had a look at that prog and its actually a browser plugin for managing site passwords and forms, supposedly its secure, I personally wouldn't trust it, thanks anyway.
-
I have done it myself. We use it here at my work. We ghosts a machine wholy automatic every night, with the symantec ghost console, and then we use a vb script to make the computer join our domain, and then we installs our daily builds on the machine and tests the installed programs.
/Jörgen
-
Kewl, I'll give it a go next week. How many machines do you image each night? I've come across a few places that re-image their machines each night, but its just too impractical to do in a school, seeing as we have 400 plus workstations, and around 10 or so different models. It was something we considered doing back in the days of NT and 98, but with the advent of "manageable" group policies and "usable" mandatory profiles in 2K server we very rarely have any problems, if any. Sorry for the little insight into my rather boring, but well paid, job, I get a bit carried away sometimes.