KS-Soft. Network Management Solutions
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister    ProfileProfile    Log inLog in 

logon enabled/disabled test

 
Post new topic   Reply to topic    KS-Soft Forum Index -> Configuration, Maintenance, Troubleshooting
View previous topic :: View next topic  
Author Message
peter.egri.citrix



Joined: 05 Mar 2009
Posts: 22

PostPosted: Wed Nov 18, 2009 5:35 am    Post subject: logon enabled/disabled test Reply with quote

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
Back to top
View user's profile Send private message
KS-Soft



Joined: 03 Apr 2002
Posts: 12303
Location: USA

PostPosted: Wed Nov 18, 2009 12:47 pm    Post subject: Reply with quote

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

Quote:
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
Back to top
View user's profile Send private message Visit poster's website
peter.egri.citrix



Joined: 05 Mar 2009
Posts: 22

PostPosted: Thu Nov 19, 2009 1:56 am    Post subject: Reply with quote

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 ....
Back to top
View user's profile Send private message
KS-Soft



Joined: 03 Apr 2002
Posts: 12303
Location: USA

PostPosted: Thu Nov 19, 2009 11:51 am    Post subject: Reply with quote

Have you fixed problem by registering msscript.ocx?

Regards
Alex
Back to top
View user's profile Send private message Visit poster's website
peter.egri.citrix



Joined: 05 Mar 2009
Posts: 22

PostPosted: Fri Nov 20, 2009 7:07 am    Post subject: Reply with quote

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 .........
Back to top
View user's profile Send private message
KS-Soft



Joined: 03 Apr 2002
Posts: 12303
Location: USA

PostPosted: Fri Nov 20, 2009 1:41 pm    Post subject: Reply with quote

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:

'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
Back to top
View user's profile Send private message Visit poster's website
peter.egri.citrix



Joined: 05 Mar 2009
Posts: 22

PostPosted: Fri Mar 05, 2010 8:45 am    Post subject: Reply with quote

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
Back to top
View user's profile Send private message
KS-Soft



Joined: 03 Apr 2002
Posts: 12303
Location: USA

PostPosted: Fri Mar 05, 2010 12:31 pm    Post subject: Reply with quote

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
Back to top
View user's profile Send private message Visit poster's website
peter.egri.citrix



Joined: 05 Mar 2009
Posts: 22

PostPosted: Tue Mar 09, 2010 3:40 am    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
KS-Soft



Joined: 03 Apr 2002
Posts: 12303
Location: USA

PostPosted: Tue Mar 09, 2010 8:37 pm    Post subject: Reply with quote

Yeah, some slashes missed in my post

If you need to send non-default credentials (username and password), you should modify script a little.
Like this
Code:
'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
Back to top
View user's profile Send private message Visit poster's website
peter.egri.citrix



Joined: 05 Mar 2009
Posts: 22

PostPosted: Wed Mar 10, 2010 5:55 am    Post subject: Reply with quote

very good

this shell script is doing what it have to.




one more question:
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 ?
Back to top
View user's profile Send private message
KS-Soft



Joined: 03 Apr 2002
Posts: 12303
Location: USA

PostPosted: Wed Mar 10, 2010 5:26 pm    Post subject: Reply with quote

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
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    KS-Soft Forum Index -> Configuration, Maintenance, Troubleshooting All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group

KS-Soft Forum Index