Skip to content

Commit b20792c

Browse files
committed
Dev Drop
1 parent b6a7a6f commit b20792c

File tree

11 files changed

+324
-325
lines changed

11 files changed

+324
-325
lines changed

WindowsLauncher/App.config

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
<?xml version="1.0" encoding="utf-8" ?>
2-
<configuration>
3-
<startup>
4-
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
5-
</startup>
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<configuration>
3+
<startup>
4+
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
5+
</startup>
66
</configuration>

WindowsLauncher/Program.cs

Lines changed: 132 additions & 132 deletions
Original file line numberDiff line numberDiff line change
@@ -1,132 +1,132 @@
1-
using Microsoft.Win32;
2-
using System;
3-
using System.Collections.Generic;
4-
using System.Diagnostics;
5-
using System.IO;
6-
7-
namespace mscript {
8-
class Program {
9-
static void Main(string[] args) {
10-
try {
11-
if (System.Deployment.Application.ApplicationDeployment.CurrentDeployment.IsFirstRun) {
12-
Console.WriteLine("Finishing installation...");
13-
SetAddRemoveProgramsIcon();
14-
Console.WriteLine("Installation complete. Press enter to exit.");
15-
Console.ReadLine();
16-
return;
17-
}
18-
} catch(System.Deployment.Application.InvalidDeploymentException e) {
19-
// Being run directly from the executable, so this is not the first installed run anyways.
20-
}
21-
22-
string[] activationData = null;
23-
if (AppDomain.CurrentDomain.SetupInformation.ActivationArguments != null) {
24-
activationData = AppDomain.CurrentDomain.SetupInformation.ActivationArguments.ActivationData;
25-
}
26-
string startFile = null;
27-
if (activationData != null) {
28-
// We were launched directly if this is null, otherwise
29-
// activationData[0] has the name of the file we were launched from
30-
startFile = activationData[0];
31-
}
32-
33-
string jarLocation = Registry.CurrentUser.OpenSubKey("Software\\MethodScript").GetValue("JarLocation").ToString();
34-
35-
List<string> command = new List<string>();
36-
if (startFile == null) {
37-
// start interpreter
38-
command.Add("-jar");
39-
command.Add(jarLocation);
40-
command.Add("interpreter");
41-
// Don't think these are needed here
42-
//command.Add("--location-----");
43-
//command.Add(AppDomain.CurrentDomain.BaseDirectory);
44-
} else {
45-
// launched from a *.ms file
46-
if(args.Length > 0 && args[0] == "--") {
47-
// Script passthrough to java -jar CH.jar <arguments>
48-
command.Add("-jar");
49-
command.Add(jarLocation);
50-
command.AddRange(args);
51-
} else if (System.Environment.GetEnvironmentVariable("DEBUG_MSCRIPT") != null && System.Environment.GetEnvironmentVariable("DEBUG_MSCRIPT") == "1") {
52-
// java debug mode
53-
command.Add("-Xrs");
54-
command.Add("-Xdebug");
55-
command.Add("-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=9001");
56-
command.Add("-jar");
57-
command.Add(jarLocation);
58-
command.Add("cmdline");
59-
command.Add(startFile);
60-
command.AddRange(args);
61-
} else {
62-
// Normal launch with script
63-
command.Add("-Xrs");
64-
command.Add("-jar");
65-
command.Add(jarLocation);
66-
command.Add("cmdline");
67-
command.Add(startFile);
68-
command.AddRange(args);
69-
}
70-
}
71-
72-
73-
ProcessStartInfo start = new ProcessStartInfo();
74-
start.Arguments = JoinAndEscape(command);
75-
start.FileName = "java.exe";
76-
start.UseShellExecute = false;
77-
78-
//Console.WriteLine(start.Arguments);
79-
80-
int exitCode;
81-
82-
using (Process proc = Process.Start(start)) {
83-
proc.WaitForExit();
84-
exitCode = proc.ExitCode;
85-
}
86-
87-
//Console.WriteLine("command: " + string.Join(" ", command));
88-
//Console.ReadLine();
89-
return;
90-
}
91-
92-
private static string JoinAndEscape(List<string> args) {
93-
string s = "";
94-
foreach(string arg in args) {
95-
string arg2 = arg.Replace("\\", "\\\\");
96-
arg2 = arg2.Replace("\"", "\\\"");
97-
arg2 = "\"" + arg2 + "\"";
98-
s += arg2;
99-
s += " ";
100-
}
101-
return s;
102-
}
103-
104-
private static void SetAddRemoveProgramsIcon() {
105-
try {
106-
string assemblyDescription = "MethodScript";
107-
108-
//the icon is included in this program
109-
string iconSourcePath = Path.Combine(System.Windows.Forms.Application.StartupPath, "commandhelper_icon.ico");
110-
//Console.WriteLine("iconSourcePath: " + iconSourcePath);
111-
//Console.WriteLine("assemblyDescription: " + assemblyDescription);
112-
113-
if (!File.Exists(iconSourcePath))
114-
return;
115-
116-
RegistryKey myUninstallKey = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Uninstall");
117-
string[] mySubKeyNames = myUninstallKey.GetSubKeyNames();
118-
for (int i = 0; i < mySubKeyNames.Length; i++) {
119-
RegistryKey myKey = myUninstallKey.OpenSubKey(mySubKeyNames[i], true);
120-
object myValue = myKey.GetValue("DisplayName");
121-
if (myValue != null && myValue.ToString() == assemblyDescription) {
122-
//Console.WriteLine("Setting iconSourcePath in " + myKey.Name);
123-
myKey.SetValue("DisplayIcon", iconSourcePath);
124-
break;
125-
}
126-
}
127-
} catch (Exception ex) {
128-
//log an error
129-
}
130-
}
131-
}
132-
}
1+
using Microsoft.Win32;
2+
using System;
3+
using System.Collections.Generic;
4+
using System.Diagnostics;
5+
using System.IO;
6+
7+
namespace mscript {
8+
class Program {
9+
static void Main(string[] args) {
10+
try {
11+
if (System.Deployment.Application.ApplicationDeployment.CurrentDeployment.IsFirstRun) {
12+
Console.WriteLine("Finishing installation...");
13+
SetAddRemoveProgramsIcon();
14+
Console.WriteLine("Installation complete. Press enter to exit.");
15+
Console.ReadLine();
16+
return;
17+
}
18+
} catch(System.Deployment.Application.InvalidDeploymentException e) {
19+
// Being run directly from the executable, so this is not the first installed run anyways.
20+
}
21+
22+
string[] activationData = null;
23+
if (AppDomain.CurrentDomain.SetupInformation.ActivationArguments != null) {
24+
activationData = AppDomain.CurrentDomain.SetupInformation.ActivationArguments.ActivationData;
25+
}
26+
string startFile = null;
27+
if (activationData != null) {
28+
// We were launched directly if this is null, otherwise
29+
// activationData[0] has the name of the file we were launched from
30+
startFile = activationData[0];
31+
}
32+
33+
string jarLocation = Registry.CurrentUser.OpenSubKey("Software\\MethodScript").GetValue("JarLocation").ToString();
34+
35+
List<string> command = new List<string>();
36+
if (startFile == null) {
37+
// start interpreter
38+
command.Add("-jar");
39+
command.Add(jarLocation);
40+
command.Add("interpreter");
41+
// Don't think these are needed here
42+
//command.Add("--location-----");
43+
//command.Add(AppDomain.CurrentDomain.BaseDirectory);
44+
} else {
45+
// launched from a *.ms file
46+
if(args.Length > 0 && args[0] == "--") {
47+
// Script passthrough to java -jar CH.jar <arguments>
48+
command.Add("-jar");
49+
command.Add(jarLocation);
50+
command.AddRange(args);
51+
} else if (System.Environment.GetEnvironmentVariable("DEBUG_MSCRIPT") != null && System.Environment.GetEnvironmentVariable("DEBUG_MSCRIPT") == "1") {
52+
// java debug mode
53+
command.Add("-Xrs");
54+
command.Add("-Xdebug");
55+
command.Add("-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=9001");
56+
command.Add("-jar");
57+
command.Add(jarLocation);
58+
command.Add("cmdline");
59+
command.Add(startFile);
60+
command.AddRange(args);
61+
} else {
62+
// Normal launch with script
63+
command.Add("-Xrs");
64+
command.Add("-jar");
65+
command.Add(jarLocation);
66+
command.Add("cmdline");
67+
command.Add(startFile);
68+
command.AddRange(args);
69+
}
70+
}
71+
72+
73+
ProcessStartInfo start = new ProcessStartInfo();
74+
start.Arguments = JoinAndEscape(command);
75+
start.FileName = "java.exe";
76+
start.UseShellExecute = false;
77+
78+
//Console.WriteLine(start.Arguments);
79+
80+
int exitCode;
81+
82+
using (Process proc = Process.Start(start)) {
83+
proc.WaitForExit();
84+
exitCode = proc.ExitCode;
85+
}
86+
87+
//Console.WriteLine("command: " + string.Join(" ", command));
88+
//Console.ReadLine();
89+
return;
90+
}
91+
92+
private static string JoinAndEscape(List<string> args) {
93+
string s = "";
94+
foreach(string arg in args) {
95+
string arg2 = arg.Replace("\\", "\\\\");
96+
arg2 = arg2.Replace("\"", "\\\"");
97+
arg2 = "\"" + arg2 + "\"";
98+
s += arg2;
99+
s += " ";
100+
}
101+
return s;
102+
}
103+
104+
private static void SetAddRemoveProgramsIcon() {
105+
try {
106+
string assemblyDescription = "MethodScript";
107+
108+
//the icon is included in this program
109+
string iconSourcePath = Path.Combine(System.Windows.Forms.Application.StartupPath, "commandhelper_icon.ico");
110+
//Console.WriteLine("iconSourcePath: " + iconSourcePath);
111+
//Console.WriteLine("assemblyDescription: " + assemblyDescription);
112+
113+
if (!File.Exists(iconSourcePath))
114+
return;
115+
116+
RegistryKey myUninstallKey = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Uninstall");
117+
string[] mySubKeyNames = myUninstallKey.GetSubKeyNames();
118+
for (int i = 0; i < mySubKeyNames.Length; i++) {
119+
RegistryKey myKey = myUninstallKey.OpenSubKey(mySubKeyNames[i], true);
120+
object myValue = myKey.GetValue("DisplayName");
121+
if (myValue != null && myValue.ToString() == assemblyDescription) {
122+
//Console.WriteLine("Setting iconSourcePath in " + myKey.Name);
123+
myKey.SetValue("DisplayIcon", iconSourcePath);
124+
break;
125+
}
126+
}
127+
} catch (Exception ex) {
128+
//log an error
129+
}
130+
}
131+
}
132+
}
Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,36 @@
1-
using System.Reflection;
2-
using System.Runtime.CompilerServices;
3-
using System.Runtime.InteropServices;
4-
5-
// General Information about an assembly is controlled through the following
6-
// set of attributes. Change these attribute values to modify the information
7-
// associated with an assembly.
8-
[assembly: AssemblyTitle("MethodScript")]
9-
[assembly: AssemblyDescription("")]
10-
[assembly: AssemblyConfiguration("")]
11-
[assembly: AssemblyCompany("")]
12-
[assembly: AssemblyProduct("MethodScript")]
13-
[assembly: AssemblyCopyright("Copyright ©2018")]
14-
[assembly: AssemblyTrademark("")]
15-
[assembly: AssemblyCulture("")]
16-
17-
// Setting ComVisible to false makes the types in this assembly not visible
18-
// to COM components. If you need to access a type in this assembly from
19-
// COM, set the ComVisible attribute to true on that type.
20-
[assembly: ComVisible(false)]
21-
22-
// The following GUID is for the ID of the typelib if this project is exposed to COM
23-
[assembly: Guid("8bc476c5-e566-4bfd-a86c-2ee0c813676f")]
24-
25-
// Version information for an assembly consists of the following four values:
26-
//
27-
// Major Version
28-
// Minor Version
29-
// Build Number
30-
// Revision
31-
//
32-
// You can specify all the values or you can default the Build and Revision Numbers
33-
// by using the '*' as shown below:
34-
// [assembly: AssemblyVersion("1.0.*")]
35-
[assembly: AssemblyVersion("1.0.0.0")]
36-
[assembly: AssemblyFileVersion("1.0.0.0")]
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
using System.Runtime.InteropServices;
4+
5+
// General Information about an assembly is controlled through the following
6+
// set of attributes. Change these attribute values to modify the information
7+
// associated with an assembly.
8+
[assembly: AssemblyTitle("MethodScript")]
9+
[assembly: AssemblyDescription("")]
10+
[assembly: AssemblyConfiguration("")]
11+
[assembly: AssemblyCompany("")]
12+
[assembly: AssemblyProduct("MethodScript")]
13+
[assembly: AssemblyCopyright("Copyright ©2018")]
14+
[assembly: AssemblyTrademark("")]
15+
[assembly: AssemblyCulture("")]
16+
17+
// Setting ComVisible to false makes the types in this assembly not visible
18+
// to COM components. If you need to access a type in this assembly from
19+
// COM, set the ComVisible attribute to true on that type.
20+
[assembly: ComVisible(false)]
21+
22+
// The following GUID is for the ID of the typelib if this project is exposed to COM
23+
[assembly: Guid("8bc476c5-e566-4bfd-a86c-2ee0c813676f")]
24+
25+
// Version information for an assembly consists of the following four values:
26+
//
27+
// Major Version
28+
// Minor Version
29+
// Build Number
30+
// Revision
31+
//
32+
// You can specify all the values or you can default the Build and Revision Numbers
33+
// by using the '*' as shown below:
34+
// [assembly: AssemblyVersion("1.0.*")]
35+
[assembly: AssemblyVersion("1.0.0.0")]
36+
[assembly: AssemblyFileVersion("1.0.0.0")]

0 commit comments

Comments
 (0)