rem rem rem rem rem rem rem rem rem rem rem rem rem rem rem rem rem rem rem rem ' Program : reged.vbs ' Version : 1.0 ' Author : Greg Griffiths (oracle@greggriffiths.org) [http://www.greggriffiths.org] ' Oracle Support from Claire Bennett - Oracle Training Reading (UK) ' Date : 04 July 2002 ' Purpose : To get Character Set information for SQL Plus from the CLient Registry ' then we write this value into a .SQL file which is called in ' GLOGIN.SQL when the user logs in. ' Usage : ' - Call this script instead of the SQL Plus executable as the TARGET or your shortcut ' - This script then parses the client registry for the required value and saves that as part of a SQL Query in a .SQL file ' - Once found it calls SQL Plus and then your GLOGIN.SQL and LOGIN.SQL are called to define the SQL Plus session ' in one of these you should include a call to load the .SQL file created as normal which runs the SQL and sets the value in the table ' Known Issues : ' - Problems if more than one Oracle Home on Client PC, you may need to amend the Registry folder we look in as needed ' - Does not work on non Windows platforms ' - May have issues on very old (e.g. 3.1) and very new (e.g. XP) versions of Windows ' - If you want to use the Command Line version of SQL Plus, you will need to amend the WSHSHELL.RUN command toward the end of this file ' - You may get an error if the .SQL file does not exist when SQL Plus is run ' Disclaimer : ' While I wrote this code and it works for me, I take no responsibility for ANYTHING that happens when ' you run this code yourself and WILL NOT be held liable in ANY way. ' References : ' http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/wsconManipulatingSystemRegistryProgrammatically.asp ' http://www.microsoft.com/Mind/0698/cutting0698.asp ' http://download-west.oracle.com/otndoc/oracle9i/901_doc/win.901/a88829/apa.htm#634080 ' http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/sgProgrammingFileSystemObject.asp ' http://www-rohan.sdsu.edu/doc/oracle/server803/A53633_01/apa.htm ' http://dbserver.irptc.unep.ch/ows-doc/ntreg03.html ' http://saturn.uab.es/oracle/win.817/a82954/ch3.htm rem rem rem rem rem rem rem rem rem rem rem rem rem rem rem rem rem rem rem rem OPTION EXPLICIT Dim my_charset ' define a var to hold our Char Set Dim key ' define the Registry key to get Dim Sh ' define our Shell object, through which we get into the Registry Dim fso ' define an object that we can use to connect to the client file system Dim tf ' define an handle for our text file Dim objNet ' define an object that we can use to connect to the Network Dim comp_name ' define a variable to hold the computer name, so we can update a table ' Create a connection to the client Set Sh = CreateObject("WScript.Shell") ' set the Registry Key location - this should be independant of the install directory, ' although having more than 1 Oracle Home on the client may cause an issue as Oracle ' increments the number at the end of the HOME key for each home, but usually only one ' Oracle instance will be installed on an end users computer key = "HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE\HOME0\NLSLANG" ' get the value and assign it to our variable my_charset=Sh.RegRead(key) ' echo the value in a pop up to the user, just to show that we have a value, ' should probably comment this out when using this for end users. 'WScript.Echo "Charset is " & my_charset ' create a connection to the Networking stuff Set objNet = WScript.CreateObject( "WScript.Network" ) ' get the computer name comp_name=objNet.ComputerName ' create the connection to the File System Set fso = CreateObject("Scripting.FileSystemObject") ' create a handle for our text file, we are going to open the file, overwriting it if it exists, creating it if not Set tf = fso.OpenTextFile("C:\myfile.sql", 2, True) ''''''''''''''' ' You may wish to use more than one TF.WRITE here to add SQL Plus commands or other SQL Statements ''''''''''''''' ' write in an UPDATE statement to update a table with the current value, updating only the row for this computer ' you may want to convert this into a Stored Procedure call to ensure that a row is Created if it does not exist to ' ensure that this SQL never fails or to update a system table which the user does not have UPDATE privelidges on. tf.write("UPDATE myTable SET client_char_set='" & my_charset & "' WHERE computer_name = '"& comp_name &"'") ' close the file tf.close ' call SQL Plus - in this case we call the GUI version rather than the Command Line version - sqlplus.exe WshShell.Run sqlplus80w