thepip3r
(Hey THIS is FUN)
2005-04-26 07:41 PM
MySQLODBC() usage questions

MySQLODBC()

1. What does this UDF do? After reading through the UDF post, I'm a little confused as to what this actually does. It sounds like it does two things, checks to see if the MySQL ODBC drivers are installed and also executes a query???

2. How do I just check a target machine to see if they have the MySQL ODBC drivers installed and if not, install them?

3. Would each person running this script need admin rights to install the MySQL ODBC drivers?

Thank you in advance...


Kdyer
(KiX Supporter)
2005-04-26 08:33 PM
Re: MySQLODBC() usage questions

piper,

This UDF automates the ODBC Configuration and creates a DSN in the Control Panel..

If you want to simply look for the existence of a MySQLODBC Driver, then you could simply look for the following file -
Code:

IF EXIST('%WINDIR%\System32\myodbc3.dll')
; do something
ELSE
; do something else
ENDIF



HTH,

Kent


thepip3r
(Hey THIS is FUN)
2005-04-26 08:36 PM
Re: MySQLODBC() usage questions

So, in order for the different users across my network to write to a MySQL database, they just need that single file?

What I want to do is when my KiX script runs during login, I want the script to write the information to a MySQL database but need to ensure that they have the driver installed first...


Kdyer
(KiX Supporter)
2005-04-26 08:40 PM
Re: MySQLODBC() usage questions

Looking back at the UDF under dependencies, you are going to need 3 files:

  • myodbc3.dll "%windir%\system32\myodbc3.dll"
  • myodbc3d.dll "%windir%\system32\myodbc3d.dll"
  • my3dsn.hlp "%windir%\help\my3dsn.hlp"


HTH,

Kent


thepip3r
(Hey THIS is FUN)
2005-04-26 08:59 PM
Re: MySQLODBC() usage questions

How would I get those copied over to computers where the users don't have admin rights to their local machine? I just logged into a computer with our domain's "test" account and I couldn't write anything to the Windows or System32 directories! ...the domain test account does not have admin rights over the local machines.

NTDOCAdministrator
(KiX Master)
2005-04-26 09:08 PM
Re: MySQLODBC() usage questions

You need an account that has Admin rights on the remote systems. Then you can copy them from your workstation to any system you want where you have Admin rights.

thepip3r
(Hey THIS is FUN)
2005-04-26 09:28 PM
Re: MySQLODBC() usage questions

ok so if I had a user account on each machine that had admin rights over it, how would I copy those files over with another user account inside of my script execution? Something like CACLs.exe?

Kdyer
(KiX Supporter)
2005-04-26 09:36 PM
Re: MySQLODBC() usage questions

In our Hand dandy - KiXtart FAQ & How to's

We see how we can deploy apps/files/etc. as an Admin -
Installing an Application as an Admin

Also, if you have a list of systems on your Domain, you can copy the files from say your desktop too.

HTH,

Kent


thepip3r
(Hey THIS is FUN)
2005-04-26 10:28 PM
Re: MySQLODBC() usage questions

What about in GPO logon scripts? That was an option I was considering that I didn't see on your FAQ and How to's. Wouldn't that run with admin rights?

Les
(KiX Master)
2005-04-26 10:30 PM
Re: MySQLODBC() usage questions

GPO Startup yes, logon no.

thepip3r
(Hey THIS is FUN)
2005-05-03 05:22 PM
Re: MySQLODBC() usage questions

Tried multiple things and am still having problems. I first off tried to write a script that would copy the three pertinent files for the MySQL ODBC drivers to all of my machines and that worked but when my script is run against them, they get an error about the provider not being available or something. And on those same systems, if I go ahead and run the .msi from MySQL on the system and then re-run the script, it runs fine so I know it has to do with the fact that I'm not copying everything that needs to be copies to the different machines. Here is the code I was using to copy the three files to the System32 directory:

Code:
;COPY MYSQL ODBC DRIVERS TO TARGET SYSTEM SO THEY CAN WRITE TO THE DATABASE
IF NOT EXIST('%WINDIR%\System32\myodbc3.dll')
COPY \\gjlk2w2ws101\softwarepushes\sms\myodbc3.dll %windir%\System32\
ENDIF

IF NOT EXIST('%WINDIR%\System32\my3dsn.hlp')
COPY \\gjlk2w2ws101\softwarepushes\sms\my3dsn.hlp %windir%\System32\
ENDIF

IF NOT EXIST('%WINDIR%\System32\myodbc3S.dll')
COPY \\gjlk2w2ws101\softwarepushes\sms\myodbc3S.dll %windir%\System32\
ENDIF



Then, since I figured that wouldn't work and I was using SMS to run this script anyways, I decided I'd just try to push the MySQL msi for the ODBC drivers through SMS also. So I created the package and it just sat in the background because it was waiting for user input. I researched the MSI on MySQL's site and couldn't find command-line switches for this file and then tried to use the command lines associated with msiexec and it turns out that there are no switches for windows installer version 2.0 and below? And myself and only a few others are using SP2 which ships windows installer version 3.0 that has command line switches! And while I can run the file with the /quiet switch, it's still running in my processes so I guess it's still waiting for user input?

So I guess my questions are this. For SMS, what else do I need to add to my script so that I can push it out to all of my systems and have it install the MySQL ODBC drivers OR what do I need to do to get a silent install of the msi???

Thanx in advance!


Kdyer
(KiX Supporter)
2005-05-03 06:53 PM
Re: MySQLODBC() usage questions

piper,

Why aren't you surronding the source and destination of the COPY Command with Quotes?

If we look at the docs, we see:
Code:

COPY "S:\MyDir\*.*" "S:\NewDir\*.*"



So, shouldn't your code be:
Code:

;COPY MYSQL ODBC DRIVERS TO TARGET SYSTEM SO THEY CAN WRITE TO THE DATABASE
IF NOT EXIST('%WINDIR%\System32\myodbc3.dll')
COPY '\\gjlk2w2ws101\softwarepushes\sms\myodbc3.dll' '%windir%\System32'
ENDIF

IF NOT EXIST('%WINDIR%\help\my3dsn.hlp')
COPY '\\gjlk2w2ws101\softwarepushes\sms\my3dsn.hlp' '%windir%\help'
ENDIF

IF NOT EXIST('%WINDIR%\System32\myodbc3S.dll')
COPY '\\gjlk2w2ws101\softwarepushes\sms\myodbc3S.dll' '%windir%\System32'
ENDIF



Note: I made a small change with the HLP file as it should go in the Help folder.

HTH,

Kent


thepip3r
(Hey THIS is FUN)
2005-05-03 07:03 PM
Re: MySQLODBC() usage questions

Thanx for the code update. I guess I just assumed they all went in the Sys32 folder. I'll make the quotes in the code. Do you know what I'm missing though that will allow mysql to work when I copy those files to the target machines??

Kdyer
(KiX Supporter)
2005-05-03 07:30 PM
Re: MySQLODBC() usage questions

Since we don't have MySQL here in house, you will have to test it out to be sure that it works.

Kent


thepip3r
(Hey THIS is FUN)
2005-05-03 07:45 PM
Re: MySQLODBC() usage questions

The script already worked prior to the quotes. I checked that using a loop to check through all of the individual computer names directories to ensure that the three files were present. What I'm missing is someone who's familiar with the MySQL ODBC drivers to tell me what ELSE I'm missing. Just copying those three files to the systems does not enable the different computers to be able to access a mysql database. I must be missing a registry key or something!!

Les
(KiX Master)
2005-05-03 08:04 PM
Re: MySQLODBC() usage questions

Quote:

I must be missing a registry key or something



I don't know Jack about MySQL but I have yet to see any ODBC that does not need to be configured in the registry. You cannot expect that just because the files are present that it will become known to the OS.


Kdyer
(KiX Supporter)
2005-05-03 08:23 PM
Re: MySQLODBC() usage questions

OK.. If we go back and look at the original post you made on this, you were asking how to make an ODBC Connnection. Is that still the case?

MySQLODBC() - Creates a ODBC connection to MySQL

If so, then yes, you do need to make some changes to the Reigstry.

I Took the liberty of modifying the ODBC code..

going to http://mysql.com , we find the new version of the ODBC driver to be - 3.51.11.

Code:

; Function: MySQLODBC()
;
; Author: Martijn (martijn@raceeend.com)
;
; Version: 1.0
;
; Action: - Checks if MyODBC is installed. If not it will be installed.
; - Creates a ODBC connection to MySQL
;
; Syntax: $ADOdb = MySQLODBC($DataSourceName, $Description, $Option, $SourcePath, Optional $DBName,

Optional $Pwd, Optional $Port, Optional $Server, Optional $Stmt, Optional $user)
;
; Parameters:
; Required
; $DataSourceName: Data Source Name of the connection
; $Description: Description of Data Source Name
; $Option: Used to select options which have affect on the drivers behaviours
; $SourcePath: Path where MyODBC files are located
; Optional
; $DBName: Database to connect to
; $Pwd: Password of database
; $Port: TCP Port used by MySQL
; $Server: IpAdress of MySQL server
; $Stmt: SQL statement which executes on connection
; $user: User which connects to database
;
; Dependencies: MyODBC files myodbc3.dll, myodbc3d.dll, my3dsn.hlp. Oh and a MySQL server http://mysql.com
;
; Remarks: Tested on Win2k with Kix 4.12
;
; Example: $DataSourceName = "MySQL-ADODB"
; $Description = "MySQL ADODB connection"
; $Option = "3" ;Default MySQL option
; $Server = "10.0.0.1"
; $SourcePath = "\\server\share\"
;
; $ADOdb = MySQLODBC($DataSourceName, $Description, $Option, $SourcePath,,,, $Server,,)

Function MySQLODBC($DSN, $Description, $Option, $SourcePath, Optional $DBName, Optional $Pwd, Optional $Port, Optional $Server, Optional $Stmt, Optional $user)
Dim $ConnKey
Dim $Driver
Dim $RegKey

$ConnKey = "HKCU\Software\ODBC\ODBC.INI\"
$Driver = "%windir%\System32\myodbc3.dll"
$RegKey = "HKLM\Software\ODBC\ODBCINST.INI\MySQL ODBC 3.51 Driver"

If NOT Exist("%windir%\system32\myodbc3.dll")
Copy $SourcePath+"myodbc3.dll" "%windir%\system32\myodbc3.dll"
EndIf
If NOT Exist("%windir%\help\my3dsn.hlp")
Copy $SourcePath+"my3dsn.hlp" "%windir%\help\my3dsn.hlp"
EndIf
If NOT Exist("%windir%\system32\myodbc3d.dll")
Copy $SourcePath+"myodbc3d.dll" "%windir%\system32\myodbc3d.dll"
EndIf
IF ReadValue("HKLM\SOFTWARE\ODBC\ODBCINST.INI\ODBC Drivers","MySQL ODBC 3.51 Driver")<>"Installed"
$x=WriteValue("HKLM\SOFTWARE\ODBC\ODBCINST.INI\ODBC Drivers","MySQL ODBC 3.51 Driver","Installed","REG_SZ")
EndIf
IF ReadValue($RegKey,"UsageCount")<>12
$x=WriteValue($RegKey,"UsageCount",12,"REG_DWORD")
EndIf
IF ReadValue($RegKey,"Driver")<>"%windir%\System32\myodbc3.dll"
$x=WriteValue($RegKey,"Driver","%windir%\System32\myodbc3.dll","REG_SZ")
EndIf
IF ReadValue($RegKey,"Setup")<>"%windir%\System32\myodbc3.dll"
$x=WriteValue($RegKey,"Setup","%windir%\System32\myodbc3.dll","REG_SZ")
EndIf
IF ReadValue($RegKey,"APILevel")<>2
$x=WriteValue($RegKey,"APILevel",2,"REG_SZ")
EndIf
IF ReadValue($RegKey,"ConnectFunctions")<>"YYN"
$x=WriteValue($RegKey,"ConnectFunctions","YYN","REG_SZ")
EndIf
IF ReadValue($RegKey,"DriverODBCVer")<>"03.51"
$x=WriteValue($RegKey,"DriverODBCVer","03.51","REG_SZ")
EndIf
IF ReadValue($RegKey,"FileUsage")<>0
$x=WriteValue($RegKey,"FileUsage",0,"REG_SZ")
EndIf
IF ReadValue($RegKey,"FileExtns")<>"*.txt"
$x=WriteValue($RegKey,"FileExtns","*.txt","REG_SZ")
EndIf
IF ReadValue($RegKey,"SQLLevel")<>1
$x=WriteValue($RegKey,"SQLLevel",1,"REG_SZ")
EndIf
IF ReadValue($RegKey,"CPTimeout")<>60
$x=WriteValue($RegKey,"CPTimeout",60,"REG_SZ")
EndIf
IF ReadValue($RegKey,"DNSHelpFile")<>"%windir%\help\my3dsn.hlp"
$x=WriteValue($RegKey,"DNSHelpFile","%windir%\help\my3dsn.hlp","REG_SZ")
EndIf
IF ReadValue("HKLM\Software\ODBC\ODBCINST.INI\ODBC Core","UsageCount")<>1
$x=WriteValue("HKLM\Software\ODBC\ODBCINST.INI\ODBC Core","UsageCount",1,"REG_DWORD")
EndIf
IF ReadValue($ConnKey+"ODBC Data Sources",$DSN)<>"MySQL ODBC 3.51 Driver"
$w = WriteValue($ConnKey+"ODBC Data Sources",$DSN,"MySQL ODBC 3.51 Driver","REG_SZ")
EndIf
IF ReadValue($ConnKey+$DSN,"Description")<>$Description
$w = WriteValue($ConnKey+$DSN,"Description",$Description,"REG_SZ")
EndIf
IF ReadValue($ConnKey+$DSN,"Database")$DatabaseName
$w = WriteValue($ConnKey+$DSN,"Database",$DBName,"REG_SZ")
EndIf
IF ReadValue($ConnKey+$DSN,"Driver")<>$Driver
$w = WriteValue($ConnKey+$DSN,"Driver",$Driver,"REG_SZ")
EndIf
IF ReadValue($ConnKey+$DSN,"Option")<>$Option
$w = WriteValue($ConnKey+$DSN,"Option",$Option,"REG_SZ")
EndIf
IF ReadValue($ConnKey+$DSN,"Password")<>$Pwd
$w = WriteValue($ConnKey+$DSN,"Password",$Pwd,"REG_SZ")
EndIf
IF ReadValue($ConnKey+$DSN,"Port")<>$Port
$w = WriteValue($ConnKey+$DSN,"Port",$Port,"REG_SZ")
EndIf
IF ReadValue($ConnKey+$DSN,"Server")<>$Server
$w = WriteValue($ConnKey+$DSN,"Server",$Server,"REG_SZ")
EndIf
IF ReadValue($ConnKey+$DSN,"Stmt")<>$Stmt
$w = WriteValue($ConnKey+$DSN,"Stmt",$Stmt,"REG_SZ")
EndIf
IF ReadValue($ConnKey+$DSN,"User")<>$User
$w = WriteValue($ConnKey+$DSN,"User",$User,"REG_SZ")
EndIf
EndFunction



HTH,

Kent


Kdyer
(KiX Supporter)
2005-05-03 08:55 PM
Re: MySQLODBC() usage questions

We can take this a step further, if you want just the drivers and to be "registered" you can do the following:
Code:

FUNCTION MYSQLODBCDRIVER()
DIM $sourcepath,$connkey,$driver,$regkey,$x
$sourcepath=@ldrive+'\programs'
$connkey = "HKCU\Software\ODBC\ODBC.INI\"
$driver = "%windir%\System32\myodbc3.dll"
$regkey = "HKLM\Software\ODBC\ODBCINST.INI\MySQL ODBC 3.51 Driver"

IF NOT Exist("%windir%\system32\myodbc3.dll")
COPY $sourcepath+"myodbc3.dll" "%windir%\system32\myodbc3.dll"
ENDIF
IF NOT Exist("%windir%\help\my3dsn.hlp")
COPY $sourcepath+"my3dsn.hlp" "%windir%\help\my3dsn.hlp"
ENDIF
IF NOT Exist("%windir%\system32\myodbc3d.dll")
COPY $sourcepath+"myodbc3d.dll" "%windir%\system32\myodbc3d.dll"
ENDIF
IF ReadValue("HKLM\SOFTWARE\ODBC\ODBCINST.INI\ODBC Drivers","MySQL ODBC 3.51 Driver")<>"Installed"
$x=WriteValue("HKLM\SOFTWARE\ODBC\ODBCINST.INI\ODBC Drivers","MySQL ODBC 3.51 Driver","Installed","REG_SZ")
ENDIF
IF ReadValue($regkey,"UsageCount")<>12
$x=WriteValue($regkey,"UsageCount",12,"REG_DWORD")
ENDIF
IF ReadValue($regkey,"Driver")<>"%windir%\System32\myodbc3.dll"
$x=WriteValue($regkey,"Driver","%windir%\System32\myodbc3.dll","REG_SZ")
ENDIF
IF ReadValue($regkey,"Setup")<>"%windir%\System32\myodbc3.dll"
$x=WriteValue($regkey,"Setup","%windir%\System32\myodbc3.dll","REG_SZ")
ENDIF
IF ReadValue($regkey,"APILevel")<>2
$x=WriteValue($regkey,"APILevel",2,"REG_SZ")
ENDIF
IF ReadValue($regkey,"ConnectFunctions")<>"YYN"
$x=WriteValue($regkey,"ConnectFunctions","YYN","REG_SZ")
ENDIF
IF ReadValue($regkey,"DriverODBCVer")<>"03.51"
$x=WriteValue($regkey,"DriverODBCVer","03.51","REG_SZ")
ENDIF
IF ReadValue($regkey,"FileUsage")<>0
$x=WriteValue($regkey,"FileUsage",0,"REG_SZ")
ENDIF
IF ReadValue($regkey,"FileExtns")<>"*.txt"
$x=WriteValue($regkey,"FileExtns","*.txt","REG_SZ")
ENDIF
IF ReadValue($regkey,"SQLLevel")<>1
$x=WriteValue($regkey,"SQLLevel",1,"REG_SZ")
ENDIF
IF ReadValue($regkey,"CPTimeout")<>60
$x=WriteValue($regkey,"CPTimeout",60,"REG_SZ")
ENDIF
IF ReadValue($regkey,"DNSHelpFile")<>"%windir%\help\my3dsn.hlp"
$x=WriteValue($regkey,"DNSHelpFile","%windir%\help\my3dsn.hlp","REG_SZ")
ENDIF
IF ReadValue("HKLM\Software\ODBC\ODBCINST.INI\ODBC Core","UsageCount")<>1
$x=WriteValue("HKLM\Software\ODBC\ODBCINST.INI\ODBC Core","UsageCount",1,"REG_DWORD")
ENDIF
ENDFUNCTION



If you need to create just the ODBC connector, provided the drivers are installed - above, then you can do the following (note: the $user parameter added for adding a global or system-wide DSN):
Code:

FUNCTION MYSQLODBC($dsn, $description, $option, $sourcepath, OPTIONAL $user, OPTIONAL $dbname,
OPTIONAL $pwd, OPTIONAL $port, OPTIONAL $server, OPTIONAL $stmt, OPTIONAL $user)
DIM $w,$connkey
IF $user
$connkey = "HKCU\Software\ODBC\ODBC.INI\"
ELSE
$connkey = "HKLM\Software\ODBC\ODBC.INI\"
ENDIF
IF ReadValue($connkey+"ODBC Data Sources",$dsn)<>"MySQL ODBC 3.51 Driver"
$w=WriteValue($connkey+"ODBC Data Sources",$dsn,"MySQL ODBC 3.51 Driver","REG_SZ")
ENDIF
IF ReadValue($connkey+$dsn,"Description")<>$description
$w=WriteValue($connkey+$dsn,"Description",$description,"REG_SZ")
ENDIF
IF ReadValue($connkey+$dsn,"Database")$DatabaseName
$w=WriteValue($connkey+$dsn,"Database",$dbname,"REG_SZ")
ENDIF
IF ReadValue($connkey+$dsn,"Driver")<>$driver
$w=WriteValue($connkey+$dsn,"Driver",$driver,"REG_SZ")
ENDIF
IF ReadValue($connkey+$dsn,"Option")<>$option
$w=WriteValue($connkey+$dsn,"Option",$option,"REG_SZ")
ENDIF
IF ReadValue($connkey+$dsn,"Password")<>$pwd
$w=WriteValue($connkey+$dsn,"Password",$pwd,"REG_SZ")
ENDIF
IF ReadValue($connkey+$dsn,"Port")<>$port
$w=WriteValue($connkey+$dsn,"Port",$port,"REG_SZ")
ENDIF
IF ReadValue($connkey+$dsn,"Server")<>$server
$w=WriteValue($connkey+$dsn,"Server",$server,"REG_SZ")
ENDIF
IF ReadValue($connkey+$dsn,"Stmt")<>$stmt
$w=WriteValue($connkey+$dsn,"Stmt",$stmt,"REG_SZ")
ENDIF
IF ReadValue($connkey+$dsn,"User")<>$user
$w=WriteValue($connkey+$dsn,"User",$user,"REG_SZ")
ENDIF
ENDFUNCTION



HTH,

Kent


thepip3r
(Hey THIS is FUN)
2005-05-03 10:03 PM
Re: MySQLODBC() usage questions

Thank you for the breakdown Kent. It's not working for me though so I think I'm going to try and find a program that "watches" your system as an install occurs so I can see exactly what the MySQL 3.51.msi install does to my system so I can account for anything that I'm missing.

Kdyer
(KiX Supporter)
2005-05-03 10:59 PM
Re: MySQLODBC() usage questions

Hmm..

Try one of the following:
inctrl5.zip
http://www.devhood.com/tools/tool_details.aspx?tool_id=432
tool_details.aspx-tool_id=432

http://regshot.yeah.net/
Regshot

On second thought, rather than "hacking" this together (I just did a RegShot) and installed the MSI from http://mysql.com and it adds in 97 registry entries.. You should really do something like:
Code:

IF 0=Exist('%windir%\system32\myodbc3d.dll')
RUN 'MsiExec.exe /i @ldrive+"Programs\MySql.msi" /qn'
ENDIF



HTH,

Kent


NTDOCAdministrator
(KiX Master)
2005-05-03 11:23 PM
Re: MySQLODBC() usage questions

I don't know that much about MySQL either, but surely you don't have to install the full MySQL on every client to have this work. That is similar to saying you need to install the full SQL Server on every desktop to connect, which is not true.

Maybe review and/or ask the specific question on a MySQL forum.


thepip3r
(Hey THIS is FUN)
2005-05-04 12:02 AM
Re: MySQLODBC() usage questions

no no no. What I was using to install is the MySQL ODBC msi. It's not mysql itself, just the ODBC driver. It's linked earlier in this thread.

Kdyer
(KiX Supporter)
2005-05-04 03:57 AM
Re: MySQLODBC() usage questions

Quote:

no no no. What I was using to install is the MySQL ODBC msi. It's not mysql itself, just the ODBC driver. It's linked earlier in this thread.




So... Isn't the last reply that I gave cover that?

Kent


Kdyer
(KiX Supporter)
2005-05-04 03:20 PM
Re: MySQLODBC() usage questions

OK.. Re-built the Function and here you go - MySQLODBC2()- Install and/or Configure ODBC for MySQL

HTH,

Kent


thepip3r
(Hey THIS is FUN)
2005-05-04 05:06 PM
Re: MySQLODBC() usage questions

what does the "/i" do for msiexec.exe in your new installation?? And the reason I was saying that it still wasn't working for me is because I did this:

Code:
;COPY MYSQL ODBC DRIVERS TO TARGET SYSTEM SO THEY CAN WRITE TO THE DATABASE
DIM $sourcepath,$connkey,$regkey,$x
$sourcepath= "\\gjlk2w2ws101\SoftwarePushes\sms\"
$connkey = "HKCU\Software\ODBC\ODBC.INI\"
$driver = "%windir%\System32\myodbc3.dll"
$regkey = "HKLM\Software\ODBC\ODBCINST.INI\MySQL ODBC 3.51 Driver"
IF @ERROR <> 0
"@ERROR: @SERROR"
ENDIF
Sleep 2

IF NOT Exist("%windir%\system32\myodbc3.dll")
COPY $sourcepath+"myodbc3.dll" "%windir%\system32\myodbc3.dll"
ENDIF

IF NOT Exist("%windir%\help\my3dsn.hlp")
COPY $sourcepath+"my3dsn.hlp" "%windir%\help\my3dsn.hlp"
ENDIF

IF NOT Exist("%windir%\system32\myodbc3s.dll")
COPY $sourcepath+"myodbc3s.dll" "%windir%\system32\myodbc3s.dll"
ENDIF

IF ReadValue("HKLM\SOFTWARE\ODBC\ODBCINST.INI\ODBC Drivers","MySQL ODBC 3.51 Driver")<>"Installed"
$x=WriteValue("HKLM\SOFTWARE\ODBC\ODBCINST.INI\ODBC Drivers","MySQL ODBC 3.51 Driver","Installed","REG_SZ")
ENDIF

IF ReadValue($regkey,"UsageCount")<>12
$x=WriteValue($regkey,"UsageCount",12,"REG_DWORD")
ENDIF

IF ReadValue($regkey,"Driver")<>"%windir%\System32\myodbc3.dll"
$x=WriteValue($regkey,"Driver","%windir%\System32\myodbc3.dll","REG_SZ")
ENDIF

IF ReadValue($regkey,"Setup")<>"%windir%\System32\myodbc3.dll"
$x=WriteValue($regkey,"Setup","%windir%\System32\myodbc3.dll","REG_SZ")
ENDIF

IF ReadValue($regkey,"APILevel")<>2
$x=WriteValue($regkey,"APILevel",2,"REG_SZ")
ENDIF

IF ReadValue($regkey,"ConnectFunctions")<>"YYN"
$x=WriteValue($regkey,"ConnectFunctions","YYN","REG_SZ")
ENDIF

IF ReadValue($regkey,"DriverODBCVer")<>"03.51"
$x=WriteValue($regkey,"DriverODBCVer","03.51","REG_SZ")
ENDIF

IF ReadValue($regkey,"FileUsage")<>0
$x=WriteValue($regkey,"FileUsage",0,"REG_SZ")
ENDIF

IF ReadValue($regkey,"FileExtns")<>"*.txt"
$x=WriteValue($regkey,"FileExtns","*.txt","REG_SZ")
ENDIF

IF ReadValue($regkey,"SQLLevel")<>1
$x=WriteValue($regkey,"SQLLevel",1,"REG_SZ")
ENDIF

IF ReadValue($regkey,"CPTimeout")<>60
$x=WriteValue($regkey,"CPTimeout",60,"REG_SZ")
ENDIF

IF ReadValue($regkey,"DNSHelpFile")<>"%windir%\help\my3dsn.hlp"
$x=WriteValue($regkey,"DNSHelpFile","%windir%\help\my3dsn.hlp","REG_SZ")
ENDIF

IF ReadValue("HKLM\Software\ODBC\ODBCINST.INI\ODBC Core","UsageCount")<>1
$x=WriteValue("HKLM\Software\ODBC\ODBCINST.INI\ODBC Core","UsageCount",1,"REG_DWORD")
ENDIF

Sleep 2



...I ran this code AFTER I uninstalled the msi installation. And after I uninstalled it, it didn't work AND after I ran this file my script didn't work and it's copying the files over correctly and creating the appropriate registry keys. That's why I was saying that I was going to look at the odbc.msi installation with a snapshot viewer to see if I could find what I was missing that was causing this script not to work correctly.


thepip3r
(Hey THIS is FUN)
2005-05-04 06:18 PM
Re: MySQLODBC() usage questions

WOOOHOO!! I think I figured out how to push it out through SMS with the MSI Package!

For systems with Windows XP SP1(or systems with Windows Installer version 2) or <, the string should be:

package.msi /qn

For systems >= Windows XP SP2 or Windows Installer version 3, the string should be:

package.msi /quiet

Thanx so much for all of the help with this one all. Kyder, I appreciate your efforts. It steered me in the right direction.


Kdyer
(KiX Supporter)
2005-05-04 06:22 PM
Re: MySQLODBC() usage questions

You should read the Microsoft Knowledgebase article - Command-Line Switches for the Microsoft Windows Installer Tool

The /i is:
Quote:


/i Package|ProductCode Installs or configures a
product.





Kent


Kdyer
(KiX Supporter)
2005-05-04 06:25 PM
Re: MySQLODBC() usage questions

Quote:

For systems with Windows XP SP1(or systems with Windows Installer version 2) or <, the string should be:

package.msi /qn

For systems >= Windows XP SP2 or Windows Installer version 3, the string should be:

package.msi /quiet





And... The difference is??
Code:

IF 0=Exist('%windir%\system32\myodbc3d.dll')
RUN 'MsiExec.exe /i @ldrive+"Programs\MySql.msi" /qn' ENDIF



You should not need the /quiet switch per - Command-Line Switches for the Microsoft Windows Installer Tool.

Can you post your finalized code on this?

HTH,

Kent


NTDOCAdministrator
(KiX Master)
2005-05-04 07:18 PM
Re: MySQLODBC() usage questions

Maybe not needed here but Undocumented on that Microsoft Link
 
Windows Installer version 2.0 introduced the /qb! switch, which runs the installation with the basic UI, additionally hiding the Cancel button on the progress dialog box.

msiexec /i application.msi /qb!


thepip3r
(Hey THIS is FUN)
2005-05-04 09:35 PM
Re: MySQLODBC() usage questions

Yes NTDOC, that's exactly the problem! Windows SP1 and < has windows installer version 2.0. It has different command line switches than windows installer version 3.0 which is the version that is installed with XP SP2.

Here is the code I'm using to push out through SMS:

Code:
$SO = SetOption('NoVarsInStrings','On')

$sp = @CSD
$os = @PRODUCTTYPE
$path = "\\gjlk2w2ws101\SoftwarePushes\sms\"
$packageName = "MyODBC-3.51.msi"

if $os = "Windows XP Professional"
if $sp = "Service Pack 1"
SHELL '%COMSPEC% /e:1024 /c '+$path+$packageName+' /qn'
endif
if $sp = "Service Pack 2"
SHELL '%COMSPEC% /e:1024 /c '+$path+$packageName+' /quiet'
endif
else
SHELL '%COMSPEC% /e:1024 /c '+$path+$packageName+' /qn'
endif



For those of you who had a differing opinion of me when I was asking about using variables in strings, you'll be proud to note that I wrote this script with them off. On the other hand, I'm not using explicit so this may cause another roasting but we'll see. =D


thepip3r
(Hey THIS is FUN)
2005-05-05 05:02 PM
Re: MySQLODBC() usage questions

Final Code I pushed out through SMS and it reported 3607 Received - 3606 Success. I just have to troubleshoot one! =D

Code:
DIM $SO,$programArray,$program
DIM $sp,$os,$path,$packageName

$SO = SetOption('NoVarsInStrings','On')

;########## CHECK TO SEE IF MyODBC DRIVERS ARE ALREADY INSTALLED ##########
$programArray = GetUninstallInfo()

For Each $program In $programArray
If $program = "MyODBC"
quit
Endif
Next


;########## INSTALL MYSQL BASED OFF OF WINDOWS INSTALLER VERSION ##########
$sp = @CSD
$os = @PRODUCTTYPE
$path = "\\gjlk2w2ws101\SoftwarePushes\sms\"
$packageName = "MyODBC-3.51.msi"

if $os = "Windows XP Professional"
if $sp = "Service Pack 1"
SHELL '%COMSPEC% /e:1024 /c '+$path+$packageName+' /qn'
endif
if $sp = "Service Pack 2"
SHELL '%COMSPEC% /e:1024 /c '+$path+$packageName+' /quiet'
endif
else
SHELL '%COMSPEC% /e:1024 /c '+$path+$packageName+' /qn'
endif


;######### START UDFs ###########
Function GetUninstallInfo()
Dim $Index, $Key, $RC, $Value, $RootKey
Dim $progs[0]
$Index = 0

$RootKey = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\"

$Key = EnumKey($RootKey, $Index)
While @Error = 0
ReDim PRESERVE $progs[$Index]
$RC = EnumValue($RootKey + $Key, 1)
If @Error = 0
$Value = ReadValue($RootKey + $Key, "DisplayName")
If $Value = ""
$Value = ReadValue($RootKey + $Key, "QuietDisplayName")
If $Value = ""
$Value = $Key
EndIf
EndIf
Else
$Value = $Key
EndIf
;? $Value
$progs[$Index] = $Value
$Index = $Index + 1
$Key = EnumKey($RootKey, $Index)
Loop
$GetUninstallInfo = $progs
EndFunction



Ok, Ok, I broke down and rewrote it for explicit. =D