![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | ConfigureSession Help PLease Help, The last part of the script ConfigureSession does not work the script works by searching the registery and if the application exists, the script will uninstalls the old application. and then installs the new application. these parts work fine. After installing the new application, the script opens (exucutes) the new application. (this works fine too) and should configures the odbc connecting the new applictaion to the database. Unfortunaley the odbc data source administrator appears promping for a manuel configuration. not connecting to the new application to the datadase. THIS IS MY BIG PROBLEM. ' This script checks to see if a program is installed ' If installed it runs the program ' If not it runs the advertised program that installs the application ' ' YourKey = "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall \{264600DE-0879-4231-9F93-9CE3D503DFC1}" strUninstallRMS6 = "\\lbnfilr002\Packages\PkgsQ-T\RMS \RMS63\uninstallRMS6.exe" If Not RegKeyExists(YourKey) Then ' Do Nothing Else set WshShell = WScript.CreateObject("WScript.Shell") WSHShell.Run strUninstallRMS6, 1 , false End If Function RegKeyExists(sRegKey) Dim oShell, RegReadReturn Set oShell = CreateObject("WScript.Shell") RegKeyExists = True sRegKey = Trim (sRegKey) If Not Right(sRegKey, 1) = "\" Then sRegKey = sRegKey & "\" End if On Error Resume Next RegReadReturn = oShell.RegRead(sRegKey) If Err Then If Left(err.description,7) = "Invalid" Then 'key not found... RegKeyExists = False 'ElseIf Left(err.description,6) = "Unable" Then 'no default value set, but key exists... 'Else 'unexpected error End if Err.clear End if On Error Goto 0 End Function 'WScript.sleep 30000 'next Dim fso_obj Dim WshShell Dim update Dim strApp Dim strWorkingDirectory 'On Error Resume Next ' ' The following variables are required for running the application set WshShell = WScript.CreateObject("WScript.Shell") set fso_obj = CreateObject("Scripting.FileSystemObject") Set fso=CreateObject("Scripting.FileSystemObject") Set env = WshShell.Environment("process") strCheck = env("USERPROFILE") & "\RMS6.txt" 'Wscript.echo strcheck strPackage = "RMS63" strInventory = "\\lbn\domaindfs$\EUDApplications \AppUseageLog.exe " & strPackage strCustomisation = "\\lbnfilr002\Packages\PkgsQ-T\RMS \RMS63\RMS63Customisation.exe" strApp = "C:\Program Files\RMS Services Limited\rms applications \serv32.exe" update = "C:\Program Files\RMS Services Limited\rms applications \checkreg.exe" strWorkingDirectory = "C:\Program Files\RMS Services Limited \rms applications" WScript.sleep 5000 If fso_obj.FileExists(strApp) then ConfigureSession if fso_obj.FileExists (strCheck) then 'RMS Conifguration not required. If required delete <pcname.txt> from user's Application Data folder strApp = Chr(34) & strApp & Chr(34) WSHShell.Run strApp, 1 , False WSHShell.Run strInventory, 1 , False Else ConfigureSession strCustomisation = Chr(34) & strCustomisation & Chr(34) WSHShell.Run strCustomisation, 1 , True ' WScript.echo "RMS Customisation Completed..! Please Run the Applications" strApp = Chr(34) & strApp & Chr(34) WSHShell.Run strApp, 1 , False End If Else strInstall = MsgBox ("Would you like to install RMS 6.3 now ?", 4, "RMS 6.3 Program not found") If strInstall = 6 then RunAdvert Else WScript.Quit End If End If WScript.Quit Sub RunAdvert strPackage = "RMS63" Set uiResource = CreateObject("UIResource.UIResourceMgr") Set programList = uiResource.GetAvailableApplications For each p in programList If p.PackageName = strPackage then uiResource.ExecuteProgram p.ID, p.PackageID, True strPackageFound = "True" Exit For End if Next If strPackageFound = "True" Then strPackage = "\\lbn\domaindfs$ \EUDApplications \ProgressbarForLockedKeyboard.hta " & chr(34) & strPackage & chr(34) 'WScript.Echo strPackage WSHShell.Run strPackage, 1 , False Else WScript.Echo strPackage & " can not be installed at the moment. Please try again later." End If Set uiResource = Nothing End Sub Sub ConfigureSession Const HKEY_CLASSES_ROOT = &H80000000 Const HKEY_CURRENT_USER = &H80000001 Const HKEY_Local_Machine = &H80000002 Const HKEY_Users = &H80000003 Const HKEY_Current_Config = &H80000005 strComputer = "." Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _ strComputer & "\root\default:StdRegProv") strKeyPath2 = "Software\ODBC\ODBC.INI\rms61_dev" strStringValueName1 = "Database" strStringValue1 = "rms61_dev" strStringValueName2 = "Driver" strStringValue2 = "C:\WINDOWS\system32\sqlsrv32.dll" strStringValueName3 = "Server" strStringValue3 = "LBNSQLR004\instance02" strStringValueName4 = "Trusted_Connection" strStringValue4 = "Yes" oReg.CreateKey HKEY_CURRENT_USER,strKeyPath2 oReg.SetStringValue HKEY_CURRENT_USER,strKeyPath2,strStringValueName1,strStringValue1 oReg.SetStringValue HKEY_CURRENT_USER,strKeyPath2,strStringValueName2,strStringValue2 oReg.SetStringValue HKEY_CURRENT_USER,strKeyPath2,strStringValueName3,strStringValue3 oReg.SetStringValue HKEY_CURRENT_USER,strKeyPath2,strStringValueName4,strStringValue4 strKeyPath5 = "Software\ODBC\ODBC.INI\ODBC Data Sources" strStringValueName5 = "rms61_dev" strStringValue5 = "SQL Server" oReg.CreateKey HKEY_CURRENT_USER,strKeyPath5 oReg.SetStringValue HKEY_CURRENT_USER,strKeyPath5,strStringValueName5,strStringValue5 End Sub |
My System Specs![]() |