Skip to content

Commit 01d18cb

Browse files
committed
installer works (locally), use separate folder for initscript (since program files requires elevated access)
1 parent 900ff31 commit 01d18cb

File tree

5 files changed

+168
-20
lines changed

5 files changed

+168
-20
lines changed

InstallerBumpVersion.bat

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
@echo off
2+
setlocal EnableDelayedExpansion
3+
4+
:: Config
5+
set VDPATH=UnityLauncherProInstaller\UnityLauncherProInstaller.vdproj
6+
set VERSIONFILE=installer-version.txt
7+
set TMPFILE=%TEMP%\vdproj_patch.tmp
8+
9+
:: Read current version
10+
set /p CURVER=<%VERSIONFILE%
11+
for /f "tokens=1-3 delims=." %%a in ("%CURVER%") do (
12+
set /a major=%%a
13+
set /a minor=%%b
14+
set /a build=%%c
15+
)
16+
17+
:: Increment build
18+
set /a build+=1
19+
if !build! gtr 65535 (
20+
set /a build=0
21+
set /a minor+=1
22+
)
23+
if !minor! gtr 255 (
24+
set /a minor=0
25+
set /a major+=1
26+
)
27+
28+
:: New version
29+
set NEWVER=!major!.!minor!.!build!
30+
31+
:: Save back to file
32+
echo !NEWVER! > %VERSIONFILE%
33+
34+
:: Prepare patch
35+
if exist "%TMPFILE%" del "%TMPFILE%"
36+
37+
:: Read and patch
38+
for /f "usebackq delims=" %%L in ("%VDPATH%") do (
39+
set "line=%%L"
40+
echo !line! | findstr /C:"ProductVersion" >nul
41+
if !errorlevel! == 0 (
42+
echo "ProductVersion" = "8:!NEWVER!" >> "%TMPFILE%"
43+
) else (
44+
echo !line! | findstr /C:"ProductCode" >nul
45+
if !errorlevel! == 0 (
46+
for /f %%G in ('"cscript //nologo InstallerGUIDGen.vbs"') do set "guid=%%G"
47+
echo "ProductCode" = "8:{!guid!}" >> "%TMPFILE%"
48+
) else (
49+
echo !line! >> "%TMPFILE%"
50+
)
51+
)
52+
)
53+
54+
:: Apply changes
55+
copy /y "%TMPFILE%" "%VDPATH%" >nul
56+
del "%TMPFILE%"
57+
58+
echo ✅ Patched version to !NEWVER! and new ProductCode
59+
pause

InstallerGUIDGen.vbs

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
' creates GUID for installer product code
2+
Set obj = CreateObject("Scriptlet.TypeLib")
3+
WScript.Echo Mid(obj.GUID, 2, 36)

UnityLauncherPro/MainWindow.xaml.cs

+26-9
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public partial class MainWindow : Window
4343
public static readonly string projectNameFile = "ProjectName.txt";
4444
public static string preferredVersion = null;
4545
public static int projectNameSetting = 0; // 0 = folder or ProjectName.txt if exists, 1=ProductName
46-
public static readonly string initScriptFileFullPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Scripts", "InitializeProject.cs");
46+
public static readonly string initScriptFileFullPath = GetInitScriptPath();
4747

4848
const string contextRegRoot = "Software\\Classes\\Directory\\Background\\shell";
4949
const string githubURL = "https://github.com/unitycoder/UnityLauncherPro";
@@ -3911,8 +3911,6 @@ private void OnPipeConnection(IAsyncResult result)
39113911
private void CheckCustomIcon()
39123912
{
39133913
string customIconPath = Path.Combine(Environment.CurrentDirectory, "icon.ico");
3914-
//Console.WriteLine(customIconPath);
3915-
39163914
if (File.Exists(customIconPath))
39173915
{
39183916
try
@@ -3921,12 +3919,7 @@ private void CheckCustomIcon()
39213919
using (var icon = new Icon(customIconPath))
39223920
{
39233921
// Convert the icon to a BitmapSource and assign it to the WPF window's Icon property
3924-
this.Icon = Imaging.CreateBitmapSourceFromHIcon(
3925-
icon.Handle,
3926-
Int32Rect.Empty,
3927-
BitmapSizeOptions.FromEmptyOptions() // Use BitmapSizeOptions here
3928-
);
3929-
3922+
this.Icon = Imaging.CreateBitmapSourceFromHIcon(icon.Handle, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());
39303923
// window icon
39313924
IconImage.Source = this.Icon;
39323925
// tray icon
@@ -4112,6 +4105,30 @@ private void btnPurgeMissingFolders_Click(object sender, RoutedEventArgs e)
41124105
SetStatus("Purged " + removedCount + " items", MessageType.Info);
41134106
}
41144107

4108+
// to handle folders where user has no write access ()
4109+
private static string GetInitScriptPath()
4110+
{
4111+
string preferredDir = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Scripts");
4112+
string fallbackDir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "UnityLauncherPro", "Scripts");
4113+
4114+
try
4115+
{
4116+
Directory.CreateDirectory(preferredDir); // safe even if it exists
4117+
return Path.Combine(preferredDir, "InitializeProject.cs");
4118+
}
4119+
catch (UnauthorizedAccessException)
4120+
{
4121+
// No write permission in Program Files etc.
4122+
}
4123+
catch (Exception ex)
4124+
{
4125+
// Optional: log other unexpected errors
4126+
Console.WriteLine("Init folder fallback: " + ex.Message);
4127+
}
4128+
4129+
Directory.CreateDirectory(fallbackDir); // always safe
4130+
return Path.Combine(fallbackDir, "InitializeProject.cs");
4131+
}
41154132

41164133
//private void menuProjectProperties_Click(object sender, RoutedEventArgs e)
41174134
//{

UnityLauncherProInstaller/UnityLauncherProInstaller.vdproj

+79-11
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@
1313
"SccProvider" = "8:"
1414
"Hierarchy"
1515
{
16+
"Entry"
17+
{
18+
"MsmKey" = "8:_56C1F622109E4E31983910358EA5BCB3"
19+
"OwnerKey" = "8:_UNDEFINED"
20+
"MsmSig" = "8:_UNDEFINED"
21+
}
1622
"Entry"
1723
{
1824
"MsmKey" = "8:_7E1343CBA8EB43B8864B8A7BBEB62BCA"
@@ -54,7 +60,7 @@
5460
"CertificateFile" = "8:"
5561
"PrivateKeyFile" = "8:"
5662
"TimeStampServer" = "8:"
57-
"InstallerBootstrapper" = "3:0"
63+
"InstallerBootstrapper" = "3:1"
5864
"BootstrapperCfg:{63ACBE69-63AA-4F98-B2B6-99F9E24495F2}"
5965
{
6066
"Enabled" = "11:TRUE"
@@ -64,10 +70,10 @@
6470
"ComponentsUrl" = "8:"
6571
"Items"
6672
{
67-
"{EDC2488A-8267-493A-A98E-7D9C3B36CDF3}:.NETFramework,Version=v4.7.2"
73+
"{EDC2488A-8267-493A-A98E-7D9C3B36CDF3}:{88EC2DC6-E1F3-4355-B2F4-CF0345A0D5AF}"
6874
{
6975
"Name" = "8:Microsoft .NET Framework 4.7.2 (x86 and x64)"
70-
"ProductCode" = "8:.NETFramework,Version=v4.7.2"
76+
"ProductCode" = "8:{88EC2DC6-E1F3-4355-B2F4-CF0345A0D5AF}"
7177
}
7278
}
7379
}
@@ -86,7 +92,7 @@
8692
"CertificateFile" = "8:"
8793
"PrivateKeyFile" = "8:"
8894
"TimeStampServer" = "8:"
89-
"InstallerBootstrapper" = "3:0"
95+
"InstallerBootstrapper" = "3:1"
9096
"BootstrapperCfg:{63ACBE69-63AA-4F98-B2B6-99F9E24495F2}"
9197
{
9298
"Enabled" = "11:FALSE"
@@ -127,6 +133,26 @@
127133
}
128134
"File"
129135
{
136+
"{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_56C1F622109E4E31983910358EA5BCB3"
137+
{
138+
"SourcePath" = "8:..\\UnityLauncherPro\\Images\\icon.ico"
139+
"TargetName" = "8:icon.ico"
140+
"Tag" = "8:"
141+
"Folder" = "8:_68B52FAF3D0E46A7BB2DA063CB0BC570"
142+
"Condition" = "8:"
143+
"Transitive" = "11:FALSE"
144+
"Vital" = "11:TRUE"
145+
"ReadOnly" = "11:FALSE"
146+
"Hidden" = "11:FALSE"
147+
"System" = "11:FALSE"
148+
"Permanent" = "11:FALSE"
149+
"SharedLegacy" = "11:FALSE"
150+
"PackageAs" = "3:1"
151+
"Register" = "3:1"
152+
"Exclude" = "11:FALSE"
153+
"IsDependency" = "11:FALSE"
154+
"IsolateTo" = "8:"
155+
}
130156
"{9F6F8455-1EF1-4B85-886A-4223BCC8E7F7}:_B4800275BE183C6B5A0394F826FCA770"
131157
{
132158
"AssemblyRegister" = "3:1"
@@ -167,7 +193,7 @@
167193
"{1525181F-901A-416C-8A58-119130FE478E}:_19ED9D0C790D4F4D9166B197E25DE46F"
168194
{
169195
"Name" = "8:#1919"
170-
"AlwaysCreate" = "11:FALSE"
196+
"AlwaysCreate" = "11:TRUE"
171197
"Condition" = "8:"
172198
"Transitive" = "11:FALSE"
173199
"Property" = "8:ProgramMenuFolder"
@@ -178,7 +204,7 @@
178204
"{1525181F-901A-416C-8A58-119130FE478E}:_2963B7ED2A0A442D83028448A89C2E88"
179205
{
180206
"Name" = "8:#1916"
181-
"AlwaysCreate" = "11:FALSE"
207+
"AlwaysCreate" = "11:TRUE"
182208
"Condition" = "8:"
183209
"Transitive" = "11:FALSE"
184210
"Property" = "8:DesktopFolder"
@@ -190,7 +216,7 @@
190216
{
191217
"DefaultLocation" = "8:[ProgramFilesFolder][Manufacturer]\\[ProductName]"
192218
"Name" = "8:#1925"
193-
"AlwaysCreate" = "11:FALSE"
219+
"AlwaysCreate" = "11:TRUE"
194220
"Condition" = "8:"
195221
"Transitive" = "11:FALSE"
196222
"Property" = "8:TARGETDIR"
@@ -214,15 +240,15 @@
214240
{
215241
"Name" = "8:Microsoft Visual Studio"
216242
"ProductName" = "8:UnityLauncherPro"
217-
"ProductCode" = "8:{76B6C40E-78F0-473A-9C61-5331E1CEEB5A}"
218-
"PackageCode" = "8:{20839B97-C305-492C-8F81-AA79296AF82D}"
243+
"ProductCode" = "8:{904A3434-1B2D-42CB-AC64-C311F3956044}"
244+
"PackageCode" = "8:{3664D852-11B6-4748-9A43-649441EEE5DF}"
219245
"UpgradeCode" = "8:{4F3ACBAF-4673-4808-9A4F-50ED1E82F59F}"
220246
"AspNetVersion" = "8:2.0.50727.0"
221247
"RestartWWWService" = "11:FALSE"
222-
"RemovePreviousVersions" = "11:FALSE"
248+
"RemovePreviousVersions" = "11:TRUE"
223249
"DetectNewerInstalledVersion" = "11:TRUE"
224250
"InstallAllUsers" = "11:FALSE"
225-
"ProductVersion" = "8:1.0.0"
251+
"ProductVersion" = "8:0.0.2"
226252
"Manufacturer" = "8:unitycoder.com"
227253
"ARPHELPTELEPHONE" = "8:"
228254
"ARPHELPLINK" = "8:https://github.com/unitycoder/UnityLauncherPro"
@@ -335,6 +361,48 @@
335361
}
336362
"Shortcut"
337363
{
364+
"{970C0BB2-C7D0-45D7-ABFA-7EC378858BC0}:_43C0E1ACE07D4DBEA0C42EC6C9AD587A"
365+
{
366+
"Name" = "8:UnityLauncherPro"
367+
"Arguments" = "8:"
368+
"Description" = "8:"
369+
"ShowCmd" = "3:1"
370+
"IconIndex" = "3:0"
371+
"Transitive" = "11:FALSE"
372+
"Target" = "8:_7E1343CBA8EB43B8864B8A7BBEB62BCA"
373+
"Folder" = "8:_19ED9D0C790D4F4D9166B197E25DE46F"
374+
"WorkingFolder" = "8:_68B52FAF3D0E46A7BB2DA063CB0BC570"
375+
"Icon" = "8:_56C1F622109E4E31983910358EA5BCB3"
376+
"Feature" = "8:"
377+
}
378+
"{970C0BB2-C7D0-45D7-ABFA-7EC378858BC0}:_C0602FC78BDC49EEBC2B8D63BF602DB2"
379+
{
380+
"Name" = "8:UnityLauncherPro"
381+
"Arguments" = "8:"
382+
"Description" = "8:"
383+
"ShowCmd" = "3:1"
384+
"IconIndex" = "3:0"
385+
"Transitive" = "11:FALSE"
386+
"Target" = "8:_68B52FAF3D0E46A7BB2DA063CB0BC570"
387+
"Folder" = "8:_68B52FAF3D0E46A7BB2DA063CB0BC570"
388+
"WorkingFolder" = "8:_19ED9D0C790D4F4D9166B197E25DE46F"
389+
"Icon" = "8:"
390+
"Feature" = "8:"
391+
}
392+
"{970C0BB2-C7D0-45D7-ABFA-7EC378858BC0}:_DC1220A510594DA78B14B2A948B17BB5"
393+
{
394+
"Name" = "8:UnityLauncherPro"
395+
"Arguments" = "8:"
396+
"Description" = "8:"
397+
"ShowCmd" = "3:1"
398+
"IconIndex" = "3:0"
399+
"Transitive" = "11:FALSE"
400+
"Target" = "8:_7E1343CBA8EB43B8864B8A7BBEB62BCA"
401+
"Folder" = "8:_2963B7ED2A0A442D83028448A89C2E88"
402+
"WorkingFolder" = "8:_68B52FAF3D0E46A7BB2DA063CB0BC570"
403+
"Icon" = "8:_56C1F622109E4E31983910358EA5BCB3"
404+
"Feature" = "8:"
405+
}
338406
}
339407
"UserInterface"
340408
{

installer-version.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
0.0.2

0 commit comments

Comments
 (0)