Page 1 of 1 1
Topic Options
#203160 - 2011-09-28 02:54 PM Windows 7 Problem : Logonscript Overwrite Registry Key
captaincrash0815 Offline
Fresh Scripter

Registered: 2005-03-16
Posts: 5
Hello,

our company change now to windows 7. Now we have a problem with a script. It don't run because UAC run on the client ? Please Help !!!

 Code:
;====================================================================
                ;
                ; CHANGE ODBC-SETTINGS FOR 32 BIT DATA SOURCES
                ;
                ;====================================================================
                ; OLD SQL Server 
                $OLDSERVER = "one"
                ; NEW SQL Server
                $NEWSERVER = "two"
                
                $MyKey="HKEY_LOCAL_MACHINE\Software\ODBC\ODBC.INI\nymeso32"
                IF EXISTKEY($MyKey)=0
                ; ---- only if data source exists and changes are not made ------
                $Server = READVALUE($MyKey, "Server")
                               IF $Server = $OLDSERVER
                               ; Name of SQL Server
                               $X = WRITEVALUE($MyKey, "Server", $NEWSERVER, "REG_SZ")
                               ENDIF
                ENDIF

; END SCRIPT FILES =====================================================


Edited by captaincrash0815 (2011-09-29 08:02 AM)

Top
#203162 - 2011-09-28 04:07 PM Re: Windows 7 Problem : Logonscript Overwrite Registry Key [Re: captaincrash0815]
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2127
Loc: Tulsa, OK
Well one problem I see at first glance....EXISTKEY() is kind of outdated that I know of. You should use KEYEXIST().

Also, I doubt this will work unless all your users have local admin rights. (Please tell me they don't.)

Top
#203163 - 2011-09-28 04:09 PM Re: Windows 7 Problem : Logonscript Overwrite Registry Key [Re: ShaneEP]
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2127
Loc: Tulsa, OK
I did a quick test...EXISTKEY does indeed seem to return 2 when it doesn't exist, not 0 whereas KEYEXIST returns 0. (at least on XP)

Sorry, I think I'm going down the wrong path here. Youre probably testing to ensure it's there, not that it's not there (so 0 is prob correct for existkey).

I would still suggest upgrading to the newer keyexist function as in the example below. Don't think it will fix your problem though. Do you know what error it is returning?
 Code:
;====================================================================
                ;
                ; CHANGE ODBC-SETTINGS FOR 32 BIT DATA SOURCES
                ;
                ;====================================================================
                ; OLD SQL Server 
                $OLDSERVER = "one"
                ; NEW SQL Server
                $NEWSERVER = "two"
                
                $MyKey="HKEY_LOCAL_MACHINE\Software\ODBC\ODBC.INI\nymeso32"
                IF KEYEXIST($MyKey)
                ; ---- only if data source exists and changes are not made ------
                $Server = READVALUE($MyKey, "Server")
                               IF $Server = $OLDSERVER
                               ; Name of SQL Server
                               $X = WRITEVALUE($MyKey, "Server", $NEWSERVER, "REG_SZ")
                               ENDIF
                ENDIF

; END SCRIPT FILES =====================================================


Edited by ShaneEP (2011-09-28 04:18 PM)

Top
#203164 - 2011-09-28 04:33 PM Re: Windows 7 Problem : Logonscript Overwrite Registry Key [Re: ShaneEP]
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4563
Loc: USA
It could also be the 32 to 64bit registry location issue too.

Check and see if you have "HKEY_LOCAL_MACHINE\Software\WOW6432NODE\ODBC\ODBC.INI\nymeso32"

Top
#203172 - 2011-09-29 08:05 AM Re: Windows 7 Problem : Logonscript Overwrite Registry Key [Re: Allen]
captaincrash0815 Offline
Fresh Scripter

Registered: 2005-03-16
Posts: 5
The scipt run when uac (User Access Control) is disabled. But when uac is enabled, the script change nothing. The client user have local admin rights.

It is possible to disable uac when the script is running or to avoid ?

Our destination is that the environment run with enabled UAC !

Thanx


Edited by captaincrash0815 (2011-09-29 08:09 AM)

Top
#203174 - 2011-09-29 02:15 PM Re: Windows 7 Problem : Logonscript Overwrite Registry Key [Re: captaincrash0815]
BradV Offline
Seasoned Scripter
****

Registered: 2006-08-16
Posts: 687
Loc: Maryland, USA
Two questions.

1. Does this have to be run in a login script? That, is can you run it from a system start up script instead? It doesn't seem to be dependent on the user's HIVE.

2. If you do have to run it in a login script, suggest you make use of Glenn's excellent strategy of:
a. Detect there is a problem in the login script.
b. Write to a server share to denote the problem.
c. Have a script running on the server, read the new file on the server share and fix the problem.

Regards,

Brad

Top
#203179 - 2011-09-29 04:31 PM Re: Windows 7 Problem : Logonscript Overwrite Registry Key [Re: BradV]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4401
Loc: New Jersey
Hey - thanks Brad!

FYI - I have some excellent code and Kix APIs to go along with my "excellent strategy". \:D I'm looking for some admins with advanced Kix skills to give it a workout!

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

Top
Page 1 of 1 1


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

Who's Online
0 registered and 394 anonymous users online.
Newest Members
batdk82, StuTheCoder, M_Moore, BeeEm, min_seow
17885 Registered Users

Generated in 0.072 seconds in which 0.039 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