1 ' JPCTB Installation Script
\r
3 ' This program is Free Software. Copyright (C) 2009 Owen Dunn
\r
5 ' Permission is hereby granted, free of charge, to any person obtaining a copy
\r
6 ' of this software and associated documentation files (the "Software"), to deal
\r
7 ' in the Software without restriction, including without limitation the rights
\r
8 ' to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
\r
9 ' copies of the Software, and to permit persons to whom the Software is fur-
\r
10 ' nished to do so, subject to the following conditions:
\r
12 ' The above copyright notice and this permission notice shall be included in
\r
13 ' all copies or substantial portions of the Software.
\r
15 ' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
\r
16 ' IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FIT-
\r
17 ' NESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
\r
18 ' AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
\r
19 ' IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CON-
\r
20 ' NECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
\r
22 ' Set this variable to true if you want this script to adjust your YPP installation
\r
23 ' if it was installed before you installed a Sun JVM. We default to false to
\r
24 ' avoid any risk of rendering a YPP installation unusable. Use this feature at
\r
29 ' If we're running under the GUI Windows Script Host, reexec
\r
30 ' ourselves under the CLI version
\r
32 If LCase(Right(Wscript.FullName, 11)) = "wscript.exe" Then
\r
33 strPath = Wscript.ScriptFullName
\r
34 strCommand = "%comspec% /k cscript " & Chr(34) & strPath & chr(34)
\r
35 Set objShell = CreateObject("Wscript.Shell")
\r
36 objShell.Run(strCommand)
\r
40 ' First, find out where Puzzle Pirates is installed
\r
42 set WshShell = CreateObject("WScript.Shell")
\r
43 set objFSO = CreateObject("Scripting.FileSystemObject")
\r
45 on error resume next
\r
46 yppuninst = WshShell.RegRead("HKCU\Software\Microsoft\Windows\CurrentVersion\Uninstall\Puzzle Pirates\UninstallString")
\r
47 if hex(Err.number) = "80070002" then
\r
48 WScript.Echo "Couldn't find YPP installation. Bailing out."
\r
52 ' back to errors killing us...
\r
56 yppdir = objFSO.GetParentFolderName(yppuninst)
\r
58 WScript.echo "Found YPP in "+yppdir
\r
60 ' Assuming we're running a Sun JVM, find out which one from
\r
61 ' the Registry and where it is
\r
63 on error resume next
\r
64 ver = WshShell.RegRead("HKLM\SOFTWARE\JavaSoft\Java Runtime Environment\CurrentVersion")
\r
65 if hex(Err.number) = "80070002" then
\r
66 WScript.Echo "Couldn't find your Sun Java VM. Bailing out."
\r
67 WScript.Echo "You will need to download and install a Sun Java VM from: "
\r
68 WScript.Echo " http://www.java.com/en/download/manual.jsp"
\r
72 home = WshShell.RegRead("HKLM\SOFTWARE\JavaSoft\Java Runtime Environment\"+ver+"\JavaHome")
\r
73 if hex(Err.number) = "80070002" then
\r
74 WScript.Echo "Couldn't find your Sun Java VM's location. Bailing out."
\r
78 ' back to errors killing us...
\r
82 WScript.echo "Found Sun Java "+ver+ " in "+home
\r
84 ' Is YPP using its own JVM or a system one?
\r
86 if (objFSO.FolderExists(yppdir+"\java")) then
\r
87 WScript.echo "YPP currently using internal Java 1.5."
\r
88 if (fullauto = true) then
\r
89 WScript.echo "...moving this aside."
\r
90 objFSO.MoveFolder yppdir+"\java", yppdir+"\java-aside"
\r
92 WScript.echo "You will need to uninstall Puzzle Pirates and then reinstall it"
\r
93 WScript.echo "for this installation to work."
\r
98 if (objFSO.FolderExists(yppdir+"\java_vm")) then
\r
99 WScript.echo "YPP currently using internal Java 1.6."
\r
100 if (fullauto = true) then
\r
101 WScript.echo "...moving this aside."
\r
102 objFSO.MoveFolder yppdir+"\java_vm", yppdir+"\java_vm-aside"
\r
104 WScript.echo "You will need to uninstall Puzzle Pirates and then reinstall it"
\r
105 WScript.echo "for this installation to work."
\r
110 ' Having furtled that, fix the desktop and start menu shortcut for non-modified YPP
\r
112 set WshSysEnv = WshShell.Environment("SYSTEM")
\r
113 winsysdir = WshSysEnv("WINDIR")+"\system32"
\r
114 strDesktop = WshShell.SpecialFolders("Desktop")
\r
115 strPrograms = WshShell.SpecialFolders("Programs")
\r
117 ' We only modify YPP shortcuts if we're in full auto mode
\r
119 if (fullauto = true) then
\r
120 set oShellLink = WshShell.CreateShortcut(strDesktop & "\Puzzle Pirates.lnk")
\r
121 oShellLink.TargetPath = winsysdir+"\javaw.exe"
\r
122 oShellLink.WorkingDirectory = yppdir
\r
125 set oShellLink = WshShell.CreateShortcut(strPrograms & "\Puzzle Pirates.lnk")
\r
126 oShellLink.TargetPath = winsysdir+"\javaw.exe"
\r
127 oShellLink.WorkingDirectory = yppdir
\r
134 ' Delete the destination folder if it currently exists
\r
135 ' FIXME find and kill any jqs or jusched processes that will stop us
\r
137 set WshvolEnv = WshShell.Environment("Volatile")
\r
138 localappdata = WshvolEnv("LOCALAPPDATA")
\r
140 ' XP doesn't have LOCALAPPDATA but does have APPDATA, although that's
\r
141 ' the roaming profile rather than the local one, so not ideal...
\r
143 if (localappdata = "") then
\r
144 localappdata = WshvolEnv("APPDATA") ' deeply undesirable if you have a roaming profile, but...
\r
147 DstFolder = localappdata+"\JPCTB"
\r
149 if (objFSO.FolderExists(DstFolder)) then
\r
150 objFSO.DeleteFolder DstFolder, true
\r
152 objFSO.CreateFolder DstFolder
\r
154 set objFolder = objFSO.GetFolder(SrcFolder)
\r
156 Wscript.echo("Copying Java directory tree...")
\r
158 objFSO.CopyFolder SrcFolder, DstFolder
\r
160 WScript.echo "Copying PCTB Uploader jar file..."
\r
161 objFSO.copyFile "PCTB-Uploader.jar",DstFolder+"\lib\ext\",true
\r
163 Wscript.echo "Adding Accessibility properties..."
\r
165 set ap = objFSO.CreateTextFile(DstFolder+"\lib\accessibility.properties", true)
\r
166 ap.WriteLine("assistive_technologies=com.tedpearson.ypp.market.MarketUploader")
\r
169 WScript.echo "Adding Desktop shortcut..."
\r
171 set WshShell = WScript.CreateObject("WScript.Shell")
\r
172 strDesktop = WshShell.SpecialFolders("Desktop")
\r
173 set oShellLink = WshShell.CreateShortcut(strDesktop & "\PCTB and Yarrg Puzzle Pirates.lnk")
\r
174 oShellLink.TargetPath = DstFolder + "\bin\javaw.exe"
\r
175 oShellLink.Arguments = "-jar getdown-dop.jar ."
\r
176 oShellLink.WorkingDirectory = yppdir
\r
177 oShellLink.IconLocation = yppdir+"\app_icon.ico, 0"
\r