-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
202 lines (170 loc) · 8.61 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
//Commented code for testing UI on MacOS
using System.Reflection.Emit;
using System.Data;
//using Internal;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
//using System.Management.Automation;
namespace dotnetcli
{
class datacollection
{
static void Main(string[] args)
{
string configversion = "prebuild";
//blank lines for ease of viewing
Console.WriteLine(@"-Thank you for using the ISBTD Windows Configurator. Version {0}", configversion);
Console.WriteLine(" ");
Console.WriteLine(@"-What is this PC's password? Needed for sudo commands");
//sudopswrd is the password to be used for sudo commands
string sudopswrd = Console.ReadLine();
//for windows
//string apprepo = System.IO.Path.GetDirectoryName(Application.ExecutablePath);
Console.WriteLine(" ");
Console.WriteLine(@"-What is the directory for the USB Drive? In Format of C:\Drivepath");
string apprepo = Console.ReadLine();
//Confirmation
Console.WriteLine(" ");
Console.WriteLine("-Recorded Sudo Password was {0}", sudopswrd);
Console.WriteLine("-Recorded directory for USB Drive was {0}", apprepo);
Console.WriteLine("-Was this correct? y/n?");
//bool usrconf = bool.Parse(Console.ReadLine());
string usrconf = Console.ReadLine();
if(usrconf == "y")
{
//confirmed yes, in this space script for installing
Console.WriteLine(" ");
Console.WriteLine("-What type of installation do you want?");
Console.WriteLine("-Options: full, debug, light,");
string installtype = Console.ReadLine();
if(installtype == "full")
{
Console.WriteLine(@"This function hasn't been made yet. Thank you for using the ISBTD Windows Configurator. Version {0}", configversion);
Environment.Exit(0);
}
else if(installtype == "debug")
{
Console.WriteLine("This function hasn't been made yet. Thank you for using the ISBTD Windows Configurator. Version {0}");
Environment.Exit(0);
}
else if(installtype == "light")
{
Console.WriteLine("This function hasn't been made yet. Thank you for using the ISBTD Windows Configurator. Version {0}");
Environment.Exit(0);
}
}
else if(usrconf == "n")
{
Console.WriteLine("You answered false, thanks for using the ISBTD Windows Configurator. Version {0}", configversion);
}
else
{
Console.WriteLine("Error. Exception reached, usrconf was not true or false.");
Console.WriteLine("Do you want to try again? y/n?");
string usrconftryagain = Console.ReadLine();
if(usrconftryagain == "y")
{
Console.WriteLine("Sorry, this feature isn't available yet.");
}
else
if(usrconftryagain == "n")
{
Console.WriteLine("The program will exit now");
Environment.Exit(0);
}
else
{
Console.WriteLine("Sorry, an exception occurred. The program will exit");
Environment.Exit(0);
}
}
}
}
// Following code credit Saurabh Rai
// https://www.c-sharpcorner.com/article/silent-installation-of-applications-using-C-Sharp/
/*
class Program
{
static void Main(string[] args)
{
ProcessFolder();
}
private static void ProcessFolder()
{
const string SOURCEFOLDERPATH = @ "applicationrepository";
if (Directory.Exists(SOURCEFOLDERPATH)) {
Console.WriteLine("Directory exists at: {0}", SOURCEFOLDERPATH);
if (Directory.GetFiles(SOURCEFOLDERPATH, "*.exe").Length > 0) {
int count = Directory.GetFiles(SOURCEFOLDERPATH, "*.exe").Length;
string[] files = Directory.GetFiles(SOURCEFOLDERPATH, "*.exe");
foreach(var file in files) {
var fileName = System.IO.Path.GetFileName(file);
var fileNameWithPath = SOURCEFOLDERPATH + "\\" + fileName;
Console.WriteLine("File Name: {0}", fileName);
Console.WriteLine("File name with path : {0}", fileNameWithPath);
//Deploy application
Console.WriteLine("Wanna install {0} application on this computer?
Press any key to contiune.
", fileName);
Console.ReadKey(); DeployApplications(fileNameWithPath); Console.ReadLine();
}
}
} else
Console.WriteLine("Directory does not exist at: {0}", SOURCEFOLDERPATH);
}
public static void DeployApplications(string executableFilePath)
{
PowerShell powerShell = null;
Console.WriteLine(" ");
Console.WriteLine("Deploying application...");
try {
using(powerShell = PowerShell.Create())
{
//here “executableFilePath” need to use in place of “
//'C:\\ApplicationRepository\\FileZilla_3.14.1_win64-setup.exe'”
//but I am using the path directly in the script.
powerShell.AddScript("$setup=Start-Process 'C:\\ApplicationRepository\\
FileZilla_3 .14 .1 _win64 - setup.exe ' -ArgumentList ' / S ' -Wait -PassThru");
Collection < PSObject > PSOutput = powerShell.Invoke(); foreach(PSObject outputItem in PSOutput) {
if (outputItem != null)
{
Console.WriteLine(outputItem.BaseObject.GetType().FullName);
Console.WriteLine(outputItem.BaseObject.ToString() + "\n");
}
}
if (powerShell.Streams.Error.Count > 0)
{
string temp = powerShell.Streams.Error.First().ToString();
Console.WriteLine("Error: {0}", temp);
} else
Console.WriteLine("Installation has completed successfully.");
}
}
catch (Exception ex)
{
Console.WriteLine("Error occured: {0}", ex.InnerException);
//throw;
} finally
{
if (powerShell != null)
powerShell.Dispose();
}
}
}
}
*/
class exit
{
static void Exit(string[] args)
{
//Code for end of program
Console.WriteLine("Thank you for using the ISBTD Windows Configurator");
Environment.Exit(0);
}
}
}