diff --git a/setup.sh b/setup.sh index 55b0b7f..d930286 100755 --- a/setup.sh +++ b/setup.sh @@ -152,16 +152,22 @@ SOFTWARE. " -echo "What do you want to do?" -select var in "Install (I accept the MIT License.)" "Uninstall" "Exit"; do - break; -done -echo "You have selected $var." - -if [[ $var == "Install (I accept the MIT License.)" ]]; then +if [[ "$1" == "--install" ]]; then Install -elif [[ $var == "Uninstall" ]]; then +elif [[ "$1" == "--uninstall" ]]; then Uninstall else - exit 0 + echo "What do you want to do?" + select var in "Install (I accept the MIT License.)" "Uninstall" "Exit"; do + break; + done + echo "You have selected $var." + + if [[ $var == "Install (I accept the MIT License.)" ]]; then + Install + elif [[ $var == "Uninstall" ]]; then + Uninstall + else + exit 0 + fi fi diff --git a/setup/Program.cs b/setup/Program.cs index 055738f..f4a7943 100644 --- a/setup/Program.cs +++ b/setup/Program.cs @@ -139,7 +139,8 @@ namespace setup return output; } - } catch (Exception ex) + } + catch (Exception ex) { return ex.ToString(); } @@ -285,12 +286,26 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE."); Console.WriteLine(""); Console.WriteLine(""); - Console.WriteLine("What do you want to do?"); - Console.WriteLine("1) Install (I accept the MIT License.)"); - Console.WriteLine("2) Uninstall"); - Console.WriteLine("3) Exit"); - Console.Write("#?"); - string cmd = Console.ReadLine(); + + string cmd = ""; + + if (args.Length > 0 && (args[0] == "--install" || args[0] == "/install")) + { + cmd = "1"; + } + else if (args.Length > 0 && (args[0] == "--uninstall" || args[0] == "/uninstall")) + { + cmd = "2"; + } + else + { + Console.WriteLine("What do you want to do?"); + Console.WriteLine("1) Install (I accept the MIT License.)"); + Console.WriteLine("2) Uninstall"); + Console.WriteLine("3) Exit"); + Console.Write("#?"); + cmd = Console.ReadLine(); + } if (cmd == "1") { @@ -314,7 +329,7 @@ SOFTWARE."); Mkdir("C:\\WINDOWS\\dc-agent\\bin"); DownLoadOneFile(downloadURL, "C:\\WINDOWS\\dc-agent\\bin\\dc-agent.exe"); - + Console.WriteLine(ExecuteOutCmd("C:\\WINDOWS\\dc-agent\\bin\\dc-agent.exe", "install")); Console.WriteLine(ExecuteOutCmd("C:\\WINDOWS\\dc-agent\\bin\\dc-agent.exe", "start"));