Updated to 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
This commit is contained in:
mzolob@gmail.com 2011-11-09 06:07:17 +00:00
parent a6d7600859
commit fc6fc5571c
4 changed files with 127 additions and 15 deletions

View File

@ -19,6 +19,7 @@ using System;
using System.IO; using System.IO;
using System.Net; using System.Net;
using libWiiSharp; using libWiiSharp;
using System.Windows.Forms;
namespace Sharpii namespace Sharpii
{ {
@ -42,6 +43,7 @@ namespace Sharpii
string arguments = ""; string arguments = "";
bool compress = true; bool compress = true;
bool saveip = false; bool saveip = false;
bool noip = true;
//Get parameters //Get parameters
for (int i = 1; i < args.Length; i++) for (int i = 1; i < args.Length; i++)
@ -55,6 +57,7 @@ namespace Sharpii
return; return;
} }
ip = args[i + 1]; ip = args[i + 1];
noip = false;
break; break;
case "-SAVEIP": case "-SAVEIP":
saveip = true; saveip = true;
@ -98,15 +101,20 @@ namespace Sharpii
{ {
if (Quiet.quiet > 2) if (Quiet.quiet > 2)
Console.WriteLine("Saving IP"); Console.WriteLine("Saving IP");
Environment.SetEnvironmentVariable("SharpiiIP", ip, EnvironmentVariableTarget.User); Environment.SetEnvironmentVariable("SharpiiIP", ip, EnvironmentVariableTarget.Machine);
} }
if (ip == "") if (ip == "")
{
if (Quiet.quiet > 2)
Console.WriteLine("No IP set, using {0}", Environment.GetEnvironmentVariable("SharpiiIP", EnvironmentVariableTarget.User));
ip = 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; libWiiSharp.Protocol proto = Protocol.JODI;
@ -166,7 +174,7 @@ namespace Sharpii
return false; 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("ERROR: WadInstaller.dll not found");
Console.WriteLine("\n\nAttemp to download? [Y/N]"); Console.WriteLine("\n\nAttemp to download? [Y/N]");
@ -178,7 +186,7 @@ namespace Sharpii
{ {
Console.Write("\nGrabbing WadInstaller.dll..."); Console.Write("\nGrabbing WadInstaller.dll...");
WebClient DLwadInstaller = new WebClient(); 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"); Console.Write("Done!\n");
} }
catch (Exception ex) catch (Exception ex)
@ -199,6 +207,7 @@ namespace Sharpii
string protocol = "JODI"; string protocol = "JODI";
bool ahb = false; bool ahb = false;
bool saveip = false; bool saveip = false;
bool noip = true;
//Get parameters //Get parameters
for (int i = 1; i < args.Length; i++) for (int i = 1; i < args.Length; i++)
@ -228,6 +237,7 @@ namespace Sharpii
return; return;
} }
ip = args[i + 1]; ip = args[i + 1];
noip = false;
break; break;
case "-SAVEIP": case "-SAVEIP":
saveip = true; saveip = true;
@ -259,7 +269,7 @@ namespace Sharpii
{ {
if (Quiet.quiet > 2) if (Quiet.quiet > 2)
Console.WriteLine("Saving IP"); Console.WriteLine("Saving IP");
Environment.SetEnvironmentVariable("SharpiiIP", ip, EnvironmentVariableTarget.User); Environment.SetEnvironmentVariable("SharpiiIP", ip, EnvironmentVariableTarget.Machine);
} }
if (ahb == true || ios == "") if (ahb == true || ios == "")
@ -270,11 +280,16 @@ namespace Sharpii
} }
if (ip == "") if (ip == "")
{
if (Quiet.quiet > 2)
Console.WriteLine("No IP set, using {0}", Environment.GetEnvironmentVariable("SharpiiIP", EnvironmentVariableTarget.User));
ip = 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; libWiiSharp.Protocol proto = Protocol.JODI;

View File

@ -19,6 +19,8 @@ using System;
using System.IO; using System.IO;
using System.Net; using System.Net;
using libWiiSharp; using libWiiSharp;
using System.Windows.Forms;
using System.Diagnostics;
namespace Sharpii namespace Sharpii
{ {
@ -32,7 +34,7 @@ namespace Sharpii
Environment.Exit(0); 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("ERROR: libWiiSharp.dll not found");
Console.WriteLine("\n\nAttemp to download? [Y/N]"); Console.WriteLine("\n\nAttemp to download? [Y/N]");
@ -44,7 +46,7 @@ namespace Sharpii
{ {
Console.Write("\nGrabbing libWiiSharp.dll..."); Console.Write("\nGrabbing libWiiSharp.dll...");
WebClient DLwadInstaller = new WebClient(); 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"); Console.Write("Done!\n");
} }
catch (Exception ex) catch (Exception ex)
@ -128,6 +130,18 @@ namespace Sharpii
gotSomewhere = true; gotSomewhere = true;
} }
if (Function == "INSTALL")
{
Install();
gotSomewhere = true;
}
if (Function == "UNINSTALL")
{
Uninstall();
gotSomewhere = true;
}
if (Function == "WHICH CAME FIRST" || Function == "WHICH CAME FIRST?" || if (Function == "WHICH CAME FIRST" || Function == "WHICH CAME FIRST?" ||
(Function == "WHICH" && args[1].ToUpper() == "CAME" && args[2].Substring(0,5).ToUpper() == "FIRST")) (Function == "WHICH" && args[1].ToUpper() == "CAME" && args[2].Substring(0,5).ToUpper() == "FIRST"))
{ {
@ -150,6 +164,65 @@ namespace Sharpii
Environment.Exit(0); 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() private static void InconspicuousNotEasterEggThingamajig()
{ {
WebClient egg = new WebClient(); string all = ""; WebClient egg = new WebClient(); string all = "";
@ -197,6 +270,13 @@ namespace Sharpii
Console.WriteLine(" use 'Sharpii [function] -h'"); Console.WriteLine(" use 'Sharpii [function] -h'");
Console.WriteLine(""); Console.WriteLine("");
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(" Global Arguments:");
Console.WriteLine(""); Console.WriteLine("");
Console.WriteLine(" -quiet | -q Try not to display any output"); Console.WriteLine(" -quiet | -q Try not to display any output");
@ -241,5 +321,5 @@ namespace Sharpii
} }
public class Version public class Version
{ {
public static string version = "1.6"; public static string version = "1.7";
} }

View File

@ -1,5 +1,5 @@
/------------------------------------------------------------------------------> /------------------------------------------------------------------------------>
Sharpii 1.6 Sharpii 1.7
<----------------------------------------------------------------> <---------------------------------------------------------------->
An app by person66 An app by person66
libWiiSharp.dll by leathl (mod by scooby74029) 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) 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 /----SOURCE
/------------------------------> /------------------------------>
@ -121,7 +132,7 @@ WiiMod by jskyboo.
I would also like to thank XFlak and JoostinOnline for doing a bit of beta 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 /----LICENSE
@ -134,6 +145,11 @@ See "LICENSE.txt" for more information.
/----CHANGELOG /----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 1.6
- SendWad now supports AHBPROT (use '-ahb') - SendWad now supports AHBPROT (use '-ahb')
- IP can now be saved in an environmental variable (SharpiiIP) - IP can now be saved in an environmental variable (SharpiiIP)

View File

@ -58,6 +58,7 @@
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Data" /> <Reference Include="System.Data" />
<Reference Include="System.Drawing" /> <Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="NUSD.cs" /> <Compile Include="NUSD.cs" />