logon enabled/disabled test

All questions related to installations, configurations and maintenance of Advanced Host Monitor (including additional tools such as RMA for Windows, RMA Manager, Web Servie, RCC).
Post Reply
peter.egri.citrix
Posts: 22
Joined: Thu Mar 05, 2009 4:45 am

logon enabled/disabled test

Post by peter.egri.citrix »

hello,
i want to controll machines if logons are enabled or disabled, trying to use .vbs script from templates.
'RMA: 301 interface not supported' error .

i wonder what is the best way to check for logins enabled/disabled using RMA and/or direct check, not using RMA
Last edited by peter.egri.citrix on Wed Mar 10, 2010 5:33 am, edited 1 time in total.
KS-Soft
Posts: 13012
Joined: Wed Apr 03, 2002 6:00 pm
Location: USA
Contact:

Post by KS-Soft »

What Windows do you use? Service Pack?
msscript.ocx was not properly registered on some Vista installations. You may registered it manualy by typing the following command in command line prompt:
regsvr32 C:\WINDOWS\system32\msscript.ocx
i wonder what is the best way to check for logins enabled/disabled using RMA and/or direct check, not using RMA
Do you need to check for locked Windows user accounts?
I think you may use NT Event Log test...
E.g. check for events with ID 626 (User Account Enabled) and 629 (User Account Disabled)

Regards
Alex
peter.egri.citrix
Posts: 22
Joined: Thu Mar 05, 2009 4:45 am

Post by peter.egri.citrix »

Hi.
I use win 2003, sp2.

monitoring server is checking more machines directly,
some are monitored via rma.

sometimes before installing new software , logons to machine are disabled so there are no users on machine and can be restarted or whatever.


Logons Enabled:
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon]
"WinStationsDisabled"="0"

Logons Disabled:
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon]
"WinStationsDisabled"="1"

i was trying to check this registry key but that error was shown.

Thank you ....
KS-Soft
Posts: 13012
Joined: Wed Apr 03, 2002 6:00 pm
Location: USA
Contact:

Post by KS-Soft »

Have you fixed problem by registering msscript.ocx?

Regards
Alex
peter.egri.citrix
Posts: 22
Joined: Thu Mar 05, 2009 4:45 am

Post by peter.egri.citrix »

well, it helped for servers controlled via remote agent.
so i set
Test By: remote agent
Test Method: Active script
so its working great.

some machines are not monitored via remote agent, there i cannot
choose what server at i want to run active script.
choosing test by: hostmonitor and i choose active script but cannot set adress of machine to check using that script.

i think i will install RMA on all machines if i have enough licences.
that will solve the problem.

thank you with that registering command .........
KS-Soft
Posts: 13012
Joined: Wed Apr 03, 2002 6:00 pm
Location: USA
Contact:

Post by KS-Soft »

Well, HostMonitor (and I think any other software) cannot execute scripts on remote system.
However you may modify your script to check registry on remote system
E.g. there is script for Shell Script test method

Code: Select all

'reads registry value on remote system
'params: [<targethostname>]
'--------------------------------------
Option Explicit

const statusAlive       = "scriptRes:Host is alive:"
const statusDead        = "scriptRes:No answer:"
const statusUnknown     = "scriptRes:Unknown:"
const statusNotResolved = "scriptRes:Unknown host:"
const statusOk          = "scriptRes:Ok:"
const statusBad         = "scriptRes:Bad:"
const statusBadContents = "scriptRes:Bad contents:"

const HKEY_LOCAL_MACHINE = &H80000002
Dim oReg, strKeyPath, strValueName, strDisabled, objArgs, strComputer
Set objArgs = WScript.Arguments 

strComputer = "."
if objArgs.Count>0 then
  'Computer name to check definition updates date 
  strComputer = objArgs(0) 
end if

Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv")
strKeyPath = "Software\Microsoft\Windows NT\CurrentVersion\Winlogon"
strValueName = "WinStationsDisabled"
oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strDisabled 

IF strDisabled="1" THEN
  WScript.StdOut.Write statusBad
ELSE
   WScript.StdOut.Write statusOk
END IF
You should use target system name as parameter for this script

Regards
Alex
Last edited by KS-Soft on Tue Mar 09, 2010 8:38 pm, edited 1 time in total.
peter.egri.citrix
Posts: 22
Joined: Thu Mar 05, 2009 4:45 am

Post by peter.egri.citrix »

Hello,

i set strComputer = "." value with hostname of target computer.
but script is not checking what i want to.
i am not so script-skilled , can you please give me a hint ?
thank you
KS-Soft
Posts: 13012
Joined: Wed Apr 03, 2002 6:00 pm
Location: USA
Contact:

Post by KS-Soft »

You don't need to monidy script code, you may specify target host name using parameter ("Params" property of the test).
As I see script works fine on our systems.

Could you please describe the problem? What is test status? Reply value? What Windows do you use? Service Pack?

If you are not sure why script does not work, you may remove /B parameter from command line and start script using HostMonitor "Lets try" option or start it from command line.
E.g. cmd /c cscript /E:VBScript scriptname.vbs targethostname

Regards
Alex
peter.egri.citrix
Posts: 22
Joined: Thu Mar 05, 2009 4:45 am

Post by peter.egri.citrix »

great.
i did change "SoftwareMicrosoft" to "Software\Microsoft"
and also "GetDWORDValue" to "GetStringValue"
now test is working as i wish.

but only on one farm, where i do not need provide user name and password when i want to access remote registry. other farm reply is - no permission. if i try 'connect remote registry' its asking for login.
i do not know if there is the way to use this script with sending logon credentials with request.

Thank You for script.
KS-Soft
Posts: 13012
Joined: Wed Apr 03, 2002 6:00 pm
Location: USA
Contact:

Post by KS-Soft »

Yeah, some slashes missed in my post :oops:

If you need to send non-default credentials (username and password), you should modify script a little.
Like this

Code: Select all

'reads registry value on remote system
'params: Params: [<targethostname> [<username> <password>]]
'-----------------------------------------------------------

Option Explicit

const statusAlive       = "scriptRes:Host is alive:"
const statusDead        = "scriptRes:No answer:"
const statusUnknown     = "scriptRes:Unknown:"
const statusNotResolved = "scriptRes:Unknown host:"
const statusOk          = "scriptRes:Ok:"
const statusBad         = "scriptRes:Bad:"
const statusBadContents = "scriptRes:Bad contents:"

const HKEY_LOCAL_MACHINE = &H80000002
DIM oReg, strKeyPath, strValueName, strDisabled, objArgs, strComputer, strLogin, strPassword
DIM objSWbemLocator, objSWbemServices
Set objArgs = WScript.Arguments 

strComputer = "."
strLogin = ""
strPassword = ""
if objArgs.Count>0 then
  'Computer name to check definition updates date 
  strComputer = objArgs(0) 
end if
if objArgs.Count>1 then 
  strLogin = objArgs(1) 
end if
if objArgs.Count>2 then 
  strPassword = objArgs(2) 
end if

strKeyPath = "Software\Microsoft\Windows NT\CurrentVersion\Winlogon"
strValueName = "WinStationsDisabled"

On Error Resume Next 
Set objSWbemLocator = CreateObject("WbemScripting.SWbemLocator")
Set objSWbemServices = objSWbemLocator.ConnectServer(strComputer, "root\default", strLogin, strPassword)
If Err.Number=0 then
  Set oReg = objSWbemServices.Get("StdRegProv")
  oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strDisabled 
  If Err.Number=0 then
    IF strDisabled="1" THEN
      WScript.StdOut.Write statusBad
    ELSE
       WScript.StdOut.Write statusOk
    END IF
  else
   WScript.StdOut.Write statusUnknown & Err.Description
  end if
else
 WScript.StdOut.Write statusUnknown & Err.Description
end if
Regards
Alex
peter.egri.citrix
Posts: 22
Joined: Thu Mar 05, 2009 4:45 am

Post by peter.egri.citrix »

very good

this shell script is doing what it have to.




one more question: 8)
one of my farms have installed passive RMAs.
4 servers - win 2003 x86 - all working correctly.
2 servers - win 2003 x64 - all working correctly except this test.

for RMA i am using 'active script' test from hostmonitor templates.


'-----------------------------------------------------------------------------
'File : RegRead.VBS
'Purpose : Sample script test for Advanced Host Monitor
'Comment : Reads registry data. Sets test's status to "Bad" when some
' application (or a user) changes address to a web page that Internet
' Explorer uses as home page
'Req : Test's option "Translate macros" must be enabled
'Language: VBScript
'Version : 1.0
'Author : KS-Soft (www.ks-soft.net)
'-----------------------------------------------------------------------------
Option Explicit

const statusAlive = "Host is alive:"
const statusDead = "No answer:"
const statusUnknown = "Unknown:"
const statusNotResolved = "Unknown host:"
const statusOk = "Ok:"
const statusBad = "Bad:"
const statusBadContents = "Bad contents:"

const IEkey = "HKLM\Software\Microsoft\Windows NT\CurrentVersion\Winlogon\WinStationsDisabled"

'---- entry point ----

FUNCTION performtest()
Dim WshShell, KeyStr
IF "%Reply%"="%"+"Reply"+"%" THEN
performtest = statusUnknown+"Please enable 'Translate macros' option"
ELSE
Set WshShell = CreateObject("WScript.Shell")
KeyStr = WshShell.RegRead(IEkey)
IF (KeyStr<>"0") THEN
performtest = statusBad+KeyStr
ELSE
performtest = statusOk+KeyStr
END IF
END IF
END FUNCTION



reply is :

RMA: 301 - Error in script:
Error number :-2147024894
Source :WshShell.RegRead
Description :Unable to open registry key "HKLM\Software\Microsoft\Windows NT\CurrentVersion\Winlogon\WinStationsDisabled" for reading.
Text :
Line :32
Column :4


but this registry key exist.

there is no C:\WINDOWS\system32\msscript.ocx
i found only M:\WINDOWS\SysWOW64\msscript.ocx (i use M system drive)
i registered it, not helping

do i have something wrong ?
KS-Soft
Posts: 13012
Joined: Wed Apr 03, 2002 6:00 pm
Location: USA
Contact:

Post by KS-Soft »

I think msscript.ocx works fine. Probably some permission issue... What account do you use to run RMA? Local system account? Local ddmin? Domain admin?

Regards
Alex
Post Reply