diff --git a/Sharpii/HBC.cs b/Sharpii/HBC.cs
index b7b87fb..d10316a 100644
--- a/Sharpii/HBC.cs
+++ b/Sharpii/HBC.cs
@@ -19,6 +19,7 @@ using System;
using System.IO;
using System.Net;
using libWiiSharp;
+using System.Windows.Forms;
namespace Sharpii
{
@@ -42,6 +43,7 @@ namespace Sharpii
string arguments = "";
bool compress = true;
bool saveip = false;
+ bool noip = true;
//Get parameters
for (int i = 1; i < args.Length; i++)
@@ -55,6 +57,7 @@ namespace Sharpii
return;
}
ip = args[i + 1];
+ noip = false;
break;
case "-SAVEIP":
saveip = true;
@@ -98,15 +101,20 @@ namespace Sharpii
{
if (Quiet.quiet > 2)
Console.WriteLine("Saving IP");
- Environment.SetEnvironmentVariable("SharpiiIP", ip, EnvironmentVariableTarget.User);
+ Environment.SetEnvironmentVariable("SharpiiIP", ip, EnvironmentVariableTarget.Machine);
}
if (ip == "")
- {
- if (Quiet.quiet > 2)
- Console.WriteLine("No IP set, using {0}", Environment.GetEnvironmentVariable("SharpiiIP", EnvironmentVariableTarget.User));
ip = Environment.GetEnvironmentVariable("SharpiiIP", EnvironmentVariableTarget.User);
+ if (ip == "")
+ ip = Environment.GetEnvironmentVariable("SharpiiIP", EnvironmentVariableTarget.Machine);
+ if (ip == "")
+ {
+ Console.WriteLine("ERROR: No IP set");
+ return;
}
+ if (noip = true && Quiet.quiet > 2)
+ Console.WriteLine("No IP set, using {0}", ip);
libWiiSharp.Protocol proto = Protocol.JODI;
@@ -166,7 +174,7 @@ namespace Sharpii
return false;
}
- if (!File.Exists("WadInstaller.dll"))
+ if (!File.Exists(Path.GetDirectoryName(Application.ExecutablePath) + "\\WadInstaller.dll"))
{
Console.WriteLine("ERROR: WadInstaller.dll not found");
Console.WriteLine("\n\nAttemp to download? [Y/N]");
@@ -178,7 +186,7 @@ namespace Sharpii
{
Console.Write("\nGrabbing WadInstaller.dll...");
WebClient DLwadInstaller = new WebClient();
- DLwadInstaller.DownloadFile("http://sharpii.googlecode.com/files/WadInstaller.dll", "WadInstaller.dll");
+ DLwadInstaller.DownloadFile("http://sharpii.googlecode.com/files/WadInstaller.dll", Path.GetDirectoryName(Application.ExecutablePath) + "\\WadInstaller.dll");
Console.Write("Done!\n");
}
catch (Exception ex)
@@ -199,6 +207,7 @@ namespace Sharpii
string protocol = "JODI";
bool ahb = false;
bool saveip = false;
+ bool noip = true;
//Get parameters
for (int i = 1; i < args.Length; i++)
@@ -228,6 +237,7 @@ namespace Sharpii
return;
}
ip = args[i + 1];
+ noip = false;
break;
case "-SAVEIP":
saveip = true;
@@ -259,7 +269,7 @@ namespace Sharpii
{
if (Quiet.quiet > 2)
Console.WriteLine("Saving IP");
- Environment.SetEnvironmentVariable("SharpiiIP", ip, EnvironmentVariableTarget.User);
+ Environment.SetEnvironmentVariable("SharpiiIP", ip, EnvironmentVariableTarget.Machine);
}
if (ahb == true || ios == "")
@@ -270,11 +280,16 @@ namespace Sharpii
}
if (ip == "")
- {
- if (Quiet.quiet > 2)
- Console.WriteLine("No IP set, using {0}", Environment.GetEnvironmentVariable("SharpiiIP", EnvironmentVariableTarget.User));
ip = Environment.GetEnvironmentVariable("SharpiiIP", EnvironmentVariableTarget.User);
+ if (ip == "")
+ ip = Environment.GetEnvironmentVariable("SharpiiIP", EnvironmentVariableTarget.Machine);
+ if (ip == "")
+ {
+ Console.WriteLine("ERROR: No IP set");
+ return;
}
+ if (noip = true && Quiet.quiet > 2)
+ Console.WriteLine("No IP set, using {0}", ip);
libWiiSharp.Protocol proto = Protocol.JODI;
diff --git a/Sharpii/Program.cs b/Sharpii/Program.cs
index 11c07cf..b4918c1 100644
--- a/Sharpii/Program.cs
+++ b/Sharpii/Program.cs
@@ -19,6 +19,8 @@ using System;
using System.IO;
using System.Net;
using libWiiSharp;
+using System.Windows.Forms;
+using System.Diagnostics;
namespace Sharpii
{
@@ -32,7 +34,7 @@ namespace Sharpii
Environment.Exit(0);
}
- if (!File.Exists("libWiiSharp.dll"))
+ if (!File.Exists(Path.GetDirectoryName(Application.ExecutablePath) + "\\libWiiSharp.dll"))
{
Console.WriteLine("ERROR: libWiiSharp.dll not found");
Console.WriteLine("\n\nAttemp to download? [Y/N]");
@@ -44,7 +46,7 @@ namespace Sharpii
{
Console.Write("\nGrabbing libWiiSharp.dll...");
WebClient DLwadInstaller = new WebClient();
- DLwadInstaller.DownloadFile("http://sharpii.googlecode.com/svn/trunk/Sharpii/libWiiSharp.dll", "libWiiSharp.dll");
+ DLwadInstaller.DownloadFile("http://sharpii.googlecode.com/svn/trunk/Sharpii/libWiiSharp.dll", Path.GetDirectoryName(Application.ExecutablePath) + "\\libWiiSharp.dll");
Console.Write("Done!\n");
}
catch (Exception ex)
@@ -128,6 +130,18 @@ namespace Sharpii
gotSomewhere = true;
}
+ if (Function == "INSTALL")
+ {
+ Install();
+ gotSomewhere = true;
+ }
+
+ if (Function == "UNINSTALL")
+ {
+ Uninstall();
+ gotSomewhere = true;
+ }
+
if (Function == "WHICH CAME FIRST" || Function == "WHICH CAME FIRST?" ||
(Function == "WHICH" && args[1].ToUpper() == "CAME" && args[2].Substring(0,5).ToUpper() == "FIRST"))
{
@@ -150,6 +164,65 @@ namespace Sharpii
Environment.Exit(0);
}
+ private static void Install()
+ {
+ try
+ {
+ if (Quiet.quiet > 1)
+ Console.WriteLine("Installing Sharpii...");
+ if (Quiet.quiet > 1)
+ Console.WriteLine("Adding Variables");
+ Environment.SetEnvironmentVariable("PATH", Environment.GetEnvironmentVariable("PATH", EnvironmentVariableTarget.Machine) +
+ ";" + Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles) + "\\Sharpii\\", EnvironmentVariableTarget.Machine);
+
+ if (Quiet.quiet > 1)
+ Console.WriteLine("Creating Directory");
+ if (Directory.Exists(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles) + "\\Sharpii\\"))
+ DeleteDir.DeleteDirectory(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles) + "\\Sharpii\\");
+ Directory.CreateDirectory(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles) + "\\Sharpii\\");
+
+ if (Quiet.quiet > 1)
+ Console.WriteLine("Copying Files");
+ File.Copy(Application.ExecutablePath, Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles) + "\\Sharpii\\Sharpii.exe");
+ if (File.Exists(Path.GetDirectoryName(Application.ExecutablePath) + "\\libWiiSharp.dll"))
+ File.Copy(Path.GetDirectoryName(Application.ExecutablePath) + "\\libWiiSharp.dll", Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles) + "\\Sharpii\\libWiiSharp.dll");
+ if (File.Exists(Path.GetDirectoryName(Application.ExecutablePath) + "\\WadInstaller.dll"))
+ File.Copy(Path.GetDirectoryName(Application.ExecutablePath) + "\\WadInstaller.dll", Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles) + "\\Sharpii\\WadInstaller.dll");
+
+ if (Quiet.quiet > 1)
+ {
+ Console.WriteLine("Sharpii was successfully installed to: {0}", Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles) + "\\Sharpii\\");
+ Console.WriteLine("You can now use Sharpii in any directory!");
+ Console.WriteLine("\nNOTE: You may need to restart your computer for this to take effect");
+ }
+ return;
+ }
+ catch (Exception ex)
+ {
+ Console.WriteLine("An unknown error occured, please try again\n\nERROR DETAILS: {0}", ex.Message);
+ return;
+ }
+ }
+
+ private static void Uninstall()
+ {
+ try
+ {
+ if (Quiet.quiet > 1)
+ Console.WriteLine("Uninstalling Sharpii...");
+ string path = Environment.GetEnvironmentVariable("PATH", EnvironmentVariableTarget.Machine);
+ Environment.SetEnvironmentVariable("PATH", path.Replace(";" + Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles) + "\\Sharpii\\", ""), EnvironmentVariableTarget.Machine);
+ Process.Start("cmd.exe", "/C mode con:cols=50 lines=4 & color 0B & echo Finishing Uninstallation... & sleep 2 & rmdir /s /q " + '"' +
+ Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles) + "\\Sharpii\\" + '"' + " & CLS & echo Sharpii has been successfully uninstalled! & echo. & pause");
+ Application.Exit();
+ }
+ catch (Exception ex)
+ {
+ Console.WriteLine("An unknown error occured, please try again\n\nERROR DETAILS: {0}", ex.Message);
+ return;
+ }
+ }
+
private static void InconspicuousNotEasterEggThingamajig()
{
WebClient egg = new WebClient(); string all = "";
@@ -197,6 +270,13 @@ namespace Sharpii
Console.WriteLine(" use 'Sharpii [function] -h'");
Console.WriteLine("");
Console.WriteLine("");
+ Console.WriteLine(" Other Functions:");
+ Console.WriteLine("");
+ Console.WriteLine(" Install Install Sharpii to your computer so you can run it");
+ Console.WriteLine(" from anywhere without needing the exe");
+ Console.WriteLine(" Uninstall Uninstall Sharpii from your computer");
+ Console.WriteLine("");
+ Console.WriteLine("");
Console.WriteLine(" Global Arguments:");
Console.WriteLine("");
Console.WriteLine(" -quiet | -q Try not to display any output");
@@ -241,5 +321,5 @@ namespace Sharpii
}
public class Version
{
- public static string version = "1.6";
+ public static string version = "1.7";
}
\ No newline at end of file
diff --git a/Sharpii/README.txt b/Sharpii/README.txt
index f40a21e..b29333e 100644
--- a/Sharpii/README.txt
+++ b/Sharpii/README.txt
@@ -1,5 +1,5 @@
/------------------------------------------------------------------------------>
- Sharpii 1.6
+ Sharpii 1.7
<---------------------------------------------------------------->
An app by person66
libWiiSharp.dll by leathl (mod by scooby74029)
@@ -99,6 +99,17 @@ help with.
an ip, Sharpii will use the one saved there instead. (Also applies to SendDol)
+/----Installing Sharpii
+/------------------------------>
+
+Since version 1.7, you have been able to install Sharpii. This allows you to run
+Sharpii from anywhere without needing the exe in that directory. To install Sharpii,
+just use the command 'Sharpii install'. This will copy Sharpii to your My Programs
+directory, and create an environmental variable. To remove it, just use the command
+'Sharpii uninstall' which will remove the environmental variable, then delete Sharpii
+from My Programs.
+
+
/----SOURCE
/------------------------------>
@@ -121,7 +132,7 @@ WiiMod by jskyboo.
I would also like to thank XFlak and JoostinOnline for doing a bit of beta
-testing for me. Thanks!
+testing for me (and giving me many ideas). Thanks!
/----LICENSE
@@ -134,6 +145,11 @@ See "LICENSE.txt" for more information.
/----CHANGELOG
/------------------------------>
+1.7
+ - Sharpii can now be installed for use without the exe
+ - SharpiiIP is now a system variable, not a user one.
+ - Sharpii now looks for DLLs in the same directory as the exe
+ - Bug fixes
1.6
- SendWad now supports AHBPROT (use '-ahb')
- IP can now be saved in an environmental variable (SharpiiIP)
diff --git a/Sharpii/Sharpii.csproj b/Sharpii/Sharpii.csproj
index b64b150..04b99cf 100644
--- a/Sharpii/Sharpii.csproj
+++ b/Sharpii/Sharpii.csproj
@@ -58,6 +58,7 @@
+