Page 1 of 1 1
Topic Options
#201279 - 2010-12-23 06:18 PM @PRODUCTYPE fails due to User Profile lock
Sergey_G Offline
Just in Town

Registered: 2010-12-18
Posts: 3
Loc: Canada
Hello All,

I have written a logon script that includes the following statement to log users out of Windows 2000 systems and to log the event to the share:

 Code:
IF @PRODUCTTYPE = "Windows 2000 Professional" OR @PRODUCTTYPE = "Windows 2000 Workstation"
   
    Open (1, "\\##########################", 4)

    Writeline (1, @CRLF + @USERID + " " + @WKSTA + " " + @LDOMAIN + " " + @DATE + " " + @TIME + " " + @PRODUCTTYPE + @CRLF)

    Close (1)

    MessageBox("Windows 2000 workstation use is no longer supported on GE
                Water domains. You will be logged off after a 20 second   wait, or upon 
                pressing OK. If you require an exception, please obtain manager approval 
                and contact Helpdesk.", "LOGOFF WARNING", 0, 20)

    $RC = LOGOFF( 1 ) 

Endif

It looks like on workstations with particularly heavy User Profile lock issues (Userenv 1517 and 1524), the script may fail to detect the productype, returning <unknown:PRODUCTTYPE<unknown:. This is an intermittent event, usually cleared by reboot. When it happens, the above If statement executes for any operating system.

I have a workaround in mind, that places an exit statement prior to the logoff statement, targeting systems other than Windows 2000, for which the script should not be executing:

If @PRODUCTTYPE = "Windows Server 2003 Domain Controller" OR @PRODUCTTYPE = "Windows 7 Professional Edition" OR @PRODUCTTYPE = "Windows 7 Ultimate Edition"

Exit

EndIf

My thinking is that on a sysytem with the @PRODUCTYPE error condition, the If statement should exit the script prior to the logoff action. Could you please tell me if this is an accurate assumption? Also, is it possible to predicate an If statement on an Unknown producttype?

I have been trying to simulate the issue in lab. But when I deny access to HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion for the logon account, the script does not execute. When I remove the ProductName value, the change does not take hold until relog, and the relog fails with an LSASS error. When I deny access to the HKLM\SYSTEM\CurrentControlSet\Control\ProductOptions Registry key, @PRODUCTTYPE still returns the correct value. If you could inform me of a way to simulate the issue, it would also help greatly.

Thank you,

Sergey



Edited by Sergey_G (2011-04-14 10:25 PM)

Top
#201281 - 2010-12-23 06:59 PM Re: @PRODUCTYPE fails due to User Profile lock [Re: Sergey_G]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4572
Loc: USA
I just did a quick search on your Userenv 1517 and 1524 errors. It appears those may be coming from your AV.

This is definitely a strange kix issue and likely only in your environment. The "unknown" error is interesting because in the past I've only seen that when the macro was enclosed inside a string, which based on your code above it is not. It's possible you have a missing quote somewhere.

I would start by looking for a stray quote, or search the board for Sanity and run your code through it.

The only other thing you can try is to test for the "unknown" ...

 Code:
if instr(@producttype,"unknown")
  ? "something is wrong"
  ;do something like exit the script
endif 


By the way... if you have a number of users all writing to that INI... you are likely being overly optimistic that is catching them all. I would suggest making an error file for each pc instead and put them in a common folder.
_________________________
(... better days ahead)

Top
#201282 - 2010-12-23 07:03 PM Re: @PRODUCTYPE fails due to User Profile lock [Re: Allen]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4402
Loc: New Jersey
There's a script ready-to-customize in the script vault that will accept input on a central server and consolidate the info into a single file or database.

Also, I'd grab the Sanity UDF from my web site as it's newer than the one posted here. In fact, it was just updated this morning so I'd grab it tomorrow (or tonight after 10pm, after the nightly automatic publish from our code library.)

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#201292 - 2010-12-24 06:28 PM Re: @PRODUCTYPE fails due to User Profile lock [Re: Glenn Barnas]
Sergey_G Offline
Just in Town

Registered: 2010-12-18
Posts: 3
Loc: Canada
Much appreciated, Gentlemen!

Yeah, the User Profile lock can be caused by AV, but in our environment, it can usually be traced back to sessions being open too long with too many applications running on an older image. Installing UPHClean everywhere could help, but I cringe at the thought of proposing the intiative to be implemented on the global enterprise network. Not so much because it's a bad idea, but because the corporate philosophy of "the less change the better" is so deeply entrenched.

True, it would be too optimistic to hope to catch every error. Right now I have this bit of script to try to catch any instance of the error where the script exits, instead of logging out the user:

If @PRODUCTTYPE = "Windows Server 2003 Domain Controller" OR @PRODUCTTYPE = "Windows 7 Professional Edition" OR @PRODUCTTYPE = "Windows 7 Ultimate Edition"

Open (1, "\\##########################", 4)

Writeline (1, @CRLF + @USERID + " " + @WKSTA + " " + @LDOMAIN + " " + @DATE + " " + @TIME + " " + @PRODUCTTYPE + @CRLF)

Close (1)

Exit

EndIf

Then the logout statement follows.

I got the known offenders in the test OU, where this test exit statement runs, so I figure if I can catch even a few instances of this working, and no instances of it failing, I'll have sufficient proof of concept.

I doubt the missing quote is the cause, because the failure is only on a few machines, on which the Userenv 1517 and 1524 are particularly bad, and following reboot, the script runs fine, as it does from the start on most machines. This is why I lean towards profile lock blocking @PRODUCTTYPE from reading the relevant Registry. If I get the chance, I'll definitely try out the if instr(@producttype,"unknown") - it should shed considerable light on exactly how the "unknown" value gets treated. There certainly seems to be something different about it, as an If statement that is predicated not on "unknown", but on other explicit values, nevertheless executes when it is handed the "unknown" value. Really threw me for a loop, that did. This Sanity UDF sounds great, I will definitely check it out, and the input accept script will be very handy for when more exact data gathering is required.

Thank you both,

Sergey


Top
#201293 - 2010-12-24 07:20 PM Re: @PRODUCTYPE fails due to User Profile lock [Re: Sergey_G]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4572
Loc: USA
The reason we suggested a separate file for your errors is because of the file locking while it is being written to. If you have two users opening the file at the same time, only one of them will get write access.
_________________________
(... better days ahead)

Top
#201296 - 2010-12-25 04:56 PM Re: @PRODUCTYPE fails due to User Profile lock [Re: Allen]
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
UPHClean would probably help and we include it in our base image. That said, I don't think a logon script is the right place to enforce OS version standards. You should be able to determine centrally, the OS version and not allow it on the domain.

In what sort of (mis)managed environment would the end user be responsible for OS version?
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#201401 - 2011-01-17 02:32 AM Re: @PRODUCTYPE fails due to User Profile lock [Re: Les]
Sergey_G Offline
Just in Town

Registered: 2010-12-18
Posts: 3
Loc: Canada
heyy, Les! that mismanaged environment would be General Electric. perhaps you could do a better job with hundreds of thousands of users working in hundreds of semi-autonomous environments. anyway, it's getting managed now. true, there are other ways to handle this sort of issue in Group Policy, but i was told to do it this way. if it doesn't work, we'll try something different. people are always more willing to argue with somone else's boss, or, for that matter, with someone else's technology.

thank you for all your help, gentlemen. i have a test solution ready that will log errors - i don't think, given the realatively low incidence of the issue, concurrent writes to error log will prove to be a problem, but i do appreciate the heads up, Allen. just waiting for approval to run it. if i should find anything of possible interest to you, i'll be sure to post it. please consider this question answered.

Top
Page 1 of 1 1


Moderator:  Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 2220 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.066 seconds in which 0.035 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org