java install på Windows 7 64 bit
Jeg har dette script, men hvorfor kan jeg ikke få det til at virker i windows 7 64 bit, den siger hver gang at jave ikke er installeret selv om at den er installeret.. dette give så problemer 2 gang man køre det.Her er mit script.
'# Uninstalls all but the chosen version of Java Runtime.
'# If the current version is not installed, it installs it from the specified path.
Option Explicit
Dim wshShell, fso, strLogFile, ts, strTempDir, strTempISS, strUnString, tsIn
Dim strUninstLine, CLSID, search5, search6, search7, strJRE1, strDisplayName, strDisplayVersion
Dim strPublisher, strUninstallString, strJREUninstallString, strJREDisplayName
Dim search1, search2, search3, search4, strJREUninstallStringNEW, ret, strUninstCMD
Dim tsISS, strSetupexe, qVal, strComputername, strCurrentVersion, strInstallMST
Dim searchCurVer, CurVerFound, strArrayCount, strLogPath, strInstallCMD, strInstallMSI, strInstallLog
Dim arrayJREDisplayName()
Dim arrayJREUninstallString()
'# Change this to match the version that you don't want to have it uninstall
strCurrentVersion = "Java(TM) 6 Update 27"
'# Set these to the desired log path and current version installer location
strLogPath = "\\serv08\Alle$\Brian Kudsk EDB\+ Computer Luk\JavaLog\"
strInstallMSI = "\\serv08\alle$\Brian Kudsk EDB\Install\Java\jre1.6.0_27.msi"
strInstallMST = "\\serv08\alle$\Brian Kudsk EDB\Install\Java\sp1033.mst"
qVal = 0
strArrayCount = 0
ReDim arrayJREDisplayName(strArrayCount)
ReDim arrayJREUninstallString(strArrayCount)
Set wshShell = CreateObject("WScript.Shell")
Set fso = CreateObject("Scripting.FileSystemObject")
strComputername = wshShell.ExpandEnvironmentStrings("%COMPUTERNAME%")
'# Set this to the appropriate command line settings to do a silent MSI install
strInstallLog = strLogPath & "Java_Install_" & strComputername & ".log"
strInstallCMD = "msiexec /I """ & strInstallMSI & """ /t """ & strInstallMST & """ /QN /Lime """ & strInstallLog & """"
If Not fso.FolderExists(strLogPath) Then fso.CreateFolder(strLogPath)
strLogFile = strLogPath & "Java_Uninstall_" & strComputername & ".log"
Set ts = fso.OpenTextFile(strLogFile, 8, True)
ts.WriteLine String(120, "_")
ts.WriteLine String(120, "¯")
ts.WriteLine Now() & " - Java Runtime(s) uninstallation started..."
ts.WriteLine String(120, "_") & vbCrlf
'# Generate Registry extracts from 'Uninstall' keys.
PreFlight()
'# Kill Java Processes
KillProc()
strTempDir = wshShell.ExpandEnvironmentStrings("%temp%")
strTempISS = strTempDir & "\iss"
strUnString = " -s -a /s /f1"
Set tsIn = fso.OpenTextFile(strTempDir & "\uninstall.tmp", 1)
If Not fso.FolderExists(strTempISS) Then fso.CreateFolder(strTempISS)
Do While Not tsIn.AtEndOfStream
strUninstLine = tsIn.ReadLine
CLSID = Mid(strUninstLine, 73, 38)
search5 = Instr(strUninstLine, "JRE 1")
search6 = Instr(strUninstLine, "]")
If search5 > 0 AND search6 > 0 Then
strJRE1 = Replace(Mid(strUninstLine, search5, search6),"]","")
End If
On Error Resume Next
strDisplayName = wshShell.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\" & CLSID & "\DisplayName")
strDisplayVersion = wshShell.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\" & CLSID & "\DisplayVersion")
strPublisher = wshShell.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\" & CLSID & "\Publisher")
strUninstallString = wshShell.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\" & CLSID & "\UninstallString")
strJREUninstallString = wshShell.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\" & strJRE1 & "\UninstallString")
strJREDisplayName = wshShell.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\" & strJRE1 & "\DisplayName")
On Error Goto 0
'Search for presence of Java and Sun in DisplayName and Publisher
search1 = Instr(1, strDisplayName, "Java", 1)
search2 = Instr(1, strPublisher, "Sun", 1)
search3 = Instr(1, strDisplayName, "J2SE", 1)
search4 = Instr(1, strUninstallString, "setup.exe", 1)
search7 = InStr(1, strDisplayName, "Development", 1) + InStr(1, strDisplayName, "Java DB", 1)
'See if it is the current version
searchCurVer = InStr(1, strDisplayName, strCurrentVersion, 1)
'If it is, Show that the current version is found
If searchCurVer > 0 Then
CurVerFound = True
ElseIf strJREUninstallString <> "" Then
'# JRE 1 found
strJREUninstallStringNEW = Replace(strJREUninstallString," -f"," -s -a /s /f")
redim Preserve arrayJREDisplayName(strArrayCount)
redim Preserve arrayJREUninstallString(strArrayCount)
arrayJREDisplayName(strArrayCount) = " - Found Old JRE: " & strDisplayName & " - Version: " & strDisplayVersion & ", Uninstalling..."
arrayJREUninstallString(strArrayCount) = strJREUninstallStringNEW
strArrayCount = strArrayCount + 1
ElseIf search7 = 0 And search1 > 0 Or search3 > 0 And search2 > 0 Then
strUninstCMD = "msiexec.exe /x " & CLSID & " /norestart /qn"
If search4 > 0 Then
'# Old InstallShield setup found
Set tsISS = fso.OpenTextFile(strTempISS & "\" & CLSID & ".iss", 2, True)
'Create Response file for any Java Version
tsISS.WriteLine "[InstallShield Silent]"
tsISS.WriteLine "Version=v6.00.000"
tsISS.WriteLine "File=Response File"
tsISS.WriteLine "[File Transfer]"
tsISS.WriteLine "OverwrittenReadOnly=NoToAll"
tsISS.WriteLine "[" & CLSID & "-DlgOrder]"
tsISS.WriteLine "Dlg0=" & CLSID & "-SprintfBox-0"
tsISS.WriteLine "Count=2"
tsISS.WriteLine "Dlg1=" & CLSID & "-File Transfer"
tsISS.WriteLine "[" & CLSID & "-SprintfBox-0]"
tsISS.WriteLine "Result=1"
tsISS.WriteLine "[Application]"
tsISS.WriteLine "Name=Java 2 Runtime Environment, SE v1.4.0_01"
tsISS.WriteLine "Version=1.4.0_01"
tsISS.WriteLine "Company=JavaSoft"
tsISS.WriteLine "Lang=0009"
tsISS.WriteLine "[" & CLSID & "-File Transfer]"
tsISS.WriteLine "SharedFile=YesToAll"
tsISS.Close
strSetupexe = Left(strUninstallString, search4 + 9)
strUninstCMD = strSetupexe & strUnString & Chr(34) & strTempISS & "\" & CLSID & ".iss" & Chr(34)
End If
redim Preserve arrayJREDisplayName(strArrayCount)
redim Preserve arrayJREUninstallString(strArrayCount)
arrayJREDisplayName(strArrayCount) = " - Found Old JRE: " & strDisplayName & " - Version: " & strDisplayVersion & ", Uninstalling..."
arrayJREUninstallString(strArrayCount) = strUninstCMD
strArrayCount = strArrayCount + 1
End If
Loop
tsIn.Close
Dim I
If CurVerFound AND strArrayCount > 0 Then
ts.Writeline Now() & " - Current Version: " & strCurrentVersion & " found, continuing with uninstalls..."
For I = LBOUND(arrayJREDisplayName) to UBOUND(arrayJREDisplayName)
ts.WriteLine Now() & arrayJREDisplayName(I)
ts.WriteLine Now() & " - Uninstall String sent: " & arrayJREUninstallString(I)
ret = wshShell.Run(arrayJREUninstallString(I) , 0, True)
ts.WriteLine Now() & " - Return: " & ret
If ret <> 0 And ret <> 3010 Then qVal = 1
Next
ElseIf CurVerFound AND strArrayCount = 0 Then
ts.WriteLine Now() & " - Current version, " & strCurrentVersion & ", found."
ts.WriteLine Now() & " - No Old Java Runtime versions are installed."
qVal = 99
ElseIf Not CurVerFound Then
ts.WriteLine Now() & " - Current Java version, " & strCurrentVersion & ", not found, installing it."
ts.WriteLine Now() & " - Running Command: " & strInstallCMD
ret = wshShell.Run(strInstallCMD , 0, True)
If ret <> 0 AND ret<> 3010 Then
ts.WriteLine Now() & " - Failed to Install Java, see " & strInstallLog & " for more details. Exiting Script."
qVal = 1
ElseIf strArrayCount > 0 Then
ts.WriteLine Now() & " - Successfully installed " & strCurrentVersion & ", and logged to " & strInstallLog & "."
For I = LBOUND(arrayJREDisplayName) to UBOUND(arrayJREDisplayName)
ts.WriteLine Now() & arrayJREDisplayName(I)
ts.WriteLine Now() & " - Uninstall String sent: " & arrayJREUninstallString(I)
ret = wshShell.Run(arrayJREUninstallString(I) , 0, True)
ts.WriteLine Now() & " - Return: " & ret
If ret <> 0 And ret <> 3010 Then qVal = 1
Next
ElseIf strArrayCount = 0 Then
ts.WriteLine Now() & " - Successfully installed " & strCurrentVersion & ", and logged to " & strInstallLog & "."
ts.WriteLine Now() & " - No Old Java Runtime versions are installed."
qVal = 99
End If
End If
ts.WriteLine String(120, "_")
ts.WriteLine String(120, "¯")
ts.Close
fso.DeleteFolder(strTempISS)
fso.DeleteFile(strTempDir & "\uninstall.tmp")
WScript.Quit(qVal)
Sub PreFlight()
'# Creates temp files containing extracts from registry 'Uninstall' keys.
Dim wshShell, fso, sTemp
Set wshShell = CreateObject("WScript.Shell")
Set fso = CreateObject("Scripting.FileSystemObject")
sTemp = wshShell.ExpandEnvironmentStrings("%temp%")
wshShell.Run "REGEDIT /E %temp%\registry.tmp HKEY_LOCAL_MACHINE\SOFTWARE\microsoft\windows\currentversion\uninstall", 0, True
wshShell.Run "cmd /c type %temp%\registry.tmp | find /i ""{"" | find /i ""}]"" > %temp%\uninstall.tmp ", 0, True
wshShell.Run "cmd /c type %temp%\registry.tmp | find /i ""JRE 1"" >> %temp%\uninstall.tmp ", 0, True
If Not fso.FileExists(sTemp & "\uninstall.tmp") Then
ts.WriteLine Now() & " - No input - %temp%\uninstall.tmp Reg extract not created."
ts.WriteLine String(120, "_")
ts.WriteLine String(120, "¯")
ts.Close
WScript.Quit(1)
End If
End Sub
Sub KillProc()
'# kills jusched.exe and jqs.exe if they are running. These processes will cause the installer to fail.
Dim wshShell
Set wshShell = CreateObject("WScript.Shell")
wshShell.Run "Taskkill /F /IM jusched.exe /T", 0, True
wshShell.Run "Taskkill /F /IM jqs.exe /T", 0, True
End Sub