I am trying to get the values of the properties of an Active Directory instance.
But it keeps giving me null exceptions
The code I am using is as follows.
var xs = PowerShell.Create()
.AddScript("Get-ADComputer -Identity COM-PC-003$ -Properties * | select operatingsystem, accountexpires")
.AddCommand("out-string");
Collection<PSObject> results = xs.Invoke();
//Console.WriteLine(xs);
foreach (var str in results)
{
Console.WriteLine(str.Members["operatingsystem"].Value.ToString());
Console.ReadLine();
//System.Diagnostics.Debug.WriteLine(str.Properties["operatingsystem"].Value);
}
How can I fix this problem?
You can try to do this:
while (true) {
Console.WriteLine("Enter Hostname");
var hn = Console.ReadLine();
var xs = PowerShell.Create().AddScript(
"$comp = Get-ADComputer -Identity " + hn +
" -Properties *" + Environment.NewLine +
"$obj = New-Object -TypeName psobject" +
" -Property #{Host=$comp.operatingsystem;accountexpires = $comp.accountexpires}" +
Environment.NewLine +
"$obj1 = $obj | select -ExpandProperty Host ; $obj2 = $obj | select -ExpandProperty accountexpires ; $out = $obj1 + ' ; ' + $obj2 ; $out").AddCommand("out-string");
Collection<PSObject> results = xs.Invoke();
//Console.WriteLine(xs);
foreach (var str in results)
{
Console.WriteLine("You want to see only OS vers? If its true - enter H, also enter E for see accountexpires or A for see all info");
ConsoleKeyInfo c = Console.ReadKey();
if (c.KeyChar == 'H')
{
Console.WriteLine(str.ToString().Split(';')[0]);
Console.ReadLine();
}
if (c.KeyChar == 'E')
{
Console.WriteLine(str.ToString().Split(';')[1]);
Console.ReadLine();
}
if (c.KeyChar == 'A')
{
Console.WriteLine(str.ToString());
Console.ReadLine();
}
}
}
Related
I want to sync and up-to-date the local database and the remote database concurrently. The owner have four restaurants(A, B, C, D) at different places. He maintains same price for products and same quality in all four restaurants. So he uses remote database to change price which used to affect the changed price in all branches. All four branches and remote server have the same database structure and same tables(i.e : A branch has records also other branch. Every branch every tables are uniquely identified by id and branch field(id + branch as composite key).
Sample table (purchase)
+----+--------+------------+------------+-----+--------------------+---------------------+
| id | branch | item | unit_price | qty | added_on | last_updated |
+----+--------+------------+------------+-----+--------------------+---------------------+
| 1 | A | Pizza | 800 | 5 |2018-12-05T15:47:54 | 2018-05-11T15:47:54 |
+----+--------+------------+------------+-----+--------------------+---------------------+
| 2 | A | Chicken | 350 | 5 |2018-12-05T15:49:54 | 2018-05-11T15:50:54 |
+----+--------+------------+------------+-----+--------------------+---------------------+
| 2 | B | cappuccino | 280 | 7 |2018-12-05T15:47:24 | 2018-05-11T15:47:24 |
+----+--------+------------+------------+-----+--------------------+---------------------+
I have the following code to extract newly added record and updated record (with the field added_on and last_updated) from local database then upload and import in remote database with a timer. Here the checked time to extract records from local database is stored in a file which will use by the timer.
Now, to-up-to-date the local database(download other branch records) in every branch how can I download the newly inserted records and updated records from the remote server?
php script on remote server ( To insert on remote database)(execute.php)
<?php
try
{
$connect = mysqli_connect("localhost", "username", "password", "database");
$query = '';
$table_data = '';
$filename = "app_restaurant.json";
$data = file_get_contents($filename);
$array = json_decode($data, true);
foreach ($array as $set)
{
$tblName = $set['tableName'];
if (sizeof($set['rows']) > 0)
{
$query = '';
$colList = array();
$valList = array();
// Get list of column names
foreach ($set['rows'][0] as $colName => $dataval)
{
$colList[] = "`" . $colName . "`";
}
$query .= "INSERT INTO `" . $tblName . "` \n";
$query .= "(" . implode(",", $colList) . ")\nVALUES\n";
// Go through the rows for this table.
foreach ($set['rows'] as $idx => $row)
{
$colDataA = array();
// Get the data values for this row.
foreach ($row as $colName => $colData)
{
$colDataA[] = "'" . $colData . "'";
}
$valList[] = "(" . implode(",", $colDataA) . ")";
}
// Add values to the query.
$query .= implode(",\n", $valList) . "\n";
// If id column present, add ON DUPLICATE KEY UPDATE clause
if (in_array("`id`", $colList))
{
$query .= "ON DUPLICATE KEY UPDATE\n\t";
$tmp = array();
foreach ($colList as $idx => $colName)
{
//$tmp[] = $colName." = new.".$colName." ";
// Changed the following line to get value from current insert row data
$tmp[] = $colName . " = VALUES(" . $colName . ") ";
}
$query .= implode(",", $tmp) . "\n";
}
else
{
echo "<p><b>`id`</b> column not found. <i>ON DUPLICATE KEY UPDATE</i> clause <b>NOT</b> added.</p>\n";
echo "<p>Columns Found:<pre>" . print_r($colList, true) . "</pre></p>\n";
}
echo "<p>Insert query:<pre>$query</pre></p>";
$r = mysqli_query($connect, $query);
echo mysqli_errno($connect) . ": " . mysqli_error($connect) . "\n";
echo "<h1>" . mysqli_affected_rows($connect) . " Rows appended in .$tblName.</h1>";
}
else
{
echo "<p>No rows to insert for .$tblName.</p>";
}
}
}
catch (Exception $e)
{
echo $e->getMessage();
}
?>
file up-loader(upload.php)
<?php
$filepath = $_FILES["file"]["tmp_name"];
move_uploaded_file($filepath,"app_restaurant.json");
?>
1.create JSON file from local database
private void btnExportJson_Click(object sender, EventArgs e)
{
string filePath = #"C:\Users\testeam-PC\Desktop\app_restaurant.json";
if(File.Exists(filePath))
{
MessageBox.Show("Sorry! The file is already exists, Please restart the operation","File Exists");
File.Delete(filePath);
}
else
{
MySQL mysql = new MySQL();
var source_result = false;
source_result = mysql.check_connection(myConString);
if (source_result == false)
{
MessageBox.Show("Sorry! Unable to connect with XAMP / WAMP or MySQL.\n Please make sure that MySQL is running.", "Local Database Connection Failure");
}
else
{
// MessageBox.Show("Connected");
int count = 0;
using (var connection = new MySqlConnection(myConString))
{
connection.Open();
// get the names of all tables in the chosen database
var tableNames = new List<string>();
using (var command = new MySqlCommand(#"SELECT table_name FROM information_schema.tables where table_schema = #database", connection))
{
command.Parameters.AddWithValue("#database", "app_restaurant");
using (var reader = command.ExecuteReader())
{
while (reader.Read())
tableNames.Add(reader.GetString(0));
}
}
// open a JSON file for output; use the streaming JsonTextWriter interface to avoid high memory usage
using (var streamWriter = new StreamWriter(filePath))
// For seperate lines may be huge capacity
using (var jsonWriter = new JsonTextWriter(streamWriter) { Formatting = Newtonsoft.Json.Formatting.Indented, Indentation = 2, IndentChar = ' ' })
//using (var jsonWriter = new JsonTextWriter(streamWriter) )
{
// one array to hold all tables
jsonWriter.WriteStartArray();
foreach (var tableName in tableNames)
{
//MessageBox.Show(tableName);
count += 1;
// an object for each table
jsonWriter.WriteStartObject();
jsonWriter.WritePropertyName("tableName");
jsonWriter.WriteValue(tableName);
jsonWriter.WritePropertyName("rows");
// an array for all the rows in the table
jsonWriter.WriteStartArray();
// select all the data from each table
using (var command = new MySqlCommand(#"SELECT * FROM " + tableName + " WHERE (last_updated >= '" + local_checked_time + "') OR (added_on >= '" + local_checked_time + "')", connection))
using (var reader = command.ExecuteReader())
{
while (reader.Read())
{
// write each row as a JSON object
jsonWriter.WriteStartObject();
for (int i = 0; i < reader.FieldCount; i++)
{
jsonWriter.WritePropertyName(reader.GetName(i));
jsonWriter.WriteValue(reader.GetValue(i));
}
jsonWriter.WriteEndObject();
}
}
jsonWriter.WriteEndArray();
jsonWriter.WriteEndObject();
}
jsonWriter.WriteEndArray();
MessageBox.Show("Totally " + count + " tables circulated", "Success");
btnUploadToServer.Enabled = true;
// Application.Exit();
//btnUploadToServer_Click(sender, e);
}
}
}
}
}
2.upload the JSON file to server
private void btnUploadToServer_Click(object sender, EventArgs e)
{
bool connection = NetworkInterface.GetIsNetworkAvailable();
if (connection == true)
{
//MessageBox.Show("Internet Available");
try
{
using (WebClient client = new WebClient())
{
string filePath = #"C:\Users\testeam-PC\Desktop\app_restaurant.json";
var myUri = new Uri(#"http://youraddress.com/path/upload.php");
client.UploadFile(myUri, filePath);
client.Credentials = CredentialCache.DefaultCredentials;
}
}
catch (Exception err)
{
MessageBox.Show(err.Message);
}
MessageBox.Show("Successfully Uploaded", "Success");
btnExecuteURL.Enabled = true;
// btnExecuteURL_Click(sender, e);
}
else
{
MessageBox.Show("There is no internet connection.\n Please make sure that you have an internet connection.", "No Internet");
}
}
3.Execute the file
private void btnExecuteURL_Click(object sender, EventArgs e) {
bool connection = NetworkInterface.GetIsNetworkAvailable();
if (connection == true) {
//MessageBox.Show("Internet Available");
try {
// Launch the execution code...
System.Diagnostics.Process.Start("http://youraddress.com/path/execute.php");
}
catch(Exception err) {
MessageBox.Show(err.Message);
}
}
else {
MessageBox.Show("There is no internet connection.\n Please make sure that you have internet connection.", "No Internet");
}
}
So basically im running a script to receive the IP adress of computer, date and time an account is locked out at work and to do this im making a small gui so all the network technicians can use it, my code Currently goes
private void btnSearch_Click(object sender, EventArgs e)
{
var username = textBox1.Text;
using (var powerShellInstance = PowerShell.Create())
{
try
{
powerShellInstance.AddScript(
"Get-WinEvent -ComputerName COMPUTERNAMEHERE -FilterHashtable #{logname=LOGNAMEHERE;id=IDHERE;data=" +
username + "} |" +
"Select-Object -Property timecreated, " +
"#{label='computername';expression={$_.properties[6].value.Split(':')[3]}} " +
"Get-WinEvent -ComputerName COMPUTERNAMEHERE -FilterHashtable #{logname=LOGNAMEHERE;id=IDHERE;data=" +
username + "} | " +
"Select-Object -Property timecreated, " +
"#{label='computername';expression={$_.properties[6].value.Split(':')[3]}} " +
"Get-WinEvent -ComputerName COMPUTERNAMEHERE -FilterHashtable #{logname=LOGNAMEHERE;id=IDHERE;data=" +
username + "} | " +
"Select-Object -Property timecreated, " +
"#{label='computername';expression={$_.properties[6].value.Split(':')[3]}} ");
// invoke execution on the pipeline (collecting output)
Collection<PSObject> PSOutput = powerShellInstance.Invoke();
// loop through each output object item
foreach (PSObject outputItem in PSOutput)
{
// if null object was dumped to the pipeline during the script then a null
// object may be present here. check for null to prevent potential NRE.
if (outputItem != null)
{
listView1.Items.Add(OUTPUTHERE);
}
}
}
catch
{
listView1.Items.Add("Failed");
}
}
but it currently crashes on the part of code where i invoke it, I've never worked on power shell before so any help would be appreciated and im really sorry if this is a stupid question xD
I have been trying to convert my python code to c# code. For some reason, the c# code gets to the DirectoryInfo declaration and says the path is not found. If someone can tell me why, it would be appreciated.
This is the original python code:
def encode(path, dest):
for root_dir, dirs, files in os.walk(path, topdown=False):
for name in files:
(base, ext)=os.path.splitext(name)
input_file = os.path.join(root_dir,name)
output_file = os.path.join(dest_dir, base+".mkv")
if (os.path.exists(output_file)):
print ("skipped")
else:
subprocess.call( ["HandBrakeCLI.exe", "-i", input_file, "-o", output_file, "-e", "x264", "--aencoder", "ac3", "-s", "1", "--subtitle-default", "1" ])
This is my current c# code:
string qpath = Path.GetFullPath((Environment.CurrentDirectory + "\\Queue\\"));
if (Directory.Exists(Path.GetFullPath(qpath)))
{
var DirMKV = (Directory.GetFiles(qpath, "*.*", SearchOption.AllDirectories).Where(s => s.EndsWith(".mkv") || s.EndsWith(".mp4")).ToArray());
foreach (string file in DirMKV)
{
DirectoryInfo dirinfo = new DirectoryInfo(file);
if (dirinfo.Parent.Parent.ToString().Contains("S"))
{
string ipath = Environment.CurrentDirectory;
string dpath = ipath + #"\Queue\" + dirinfo.Parent.Parent.ToString() + #"\" + Path.GetFileName(file);
string opath = ipath + #"\Finished\" + dirinfo.Parent.Parent.ToString() + #"\" + Path.GetFileName(file);
string arg = "-i " +dpath + " -o " +opath +" -e x264 "+ " --aencoder ac3 "+ "-s 1 "+ "--subtitle-default 1";
if (!File.Exists(opath))
{
Process.Start(ipath + #"\handbrakeCLI.exe", arg);
}
}
}
}
I don't understand Python, but from what I see, your c# code and python code definitely do different things. There are bunch of things that are not clear. I have commented your code with my advice. Hopefully that will solve your issues
Commented code below
string qpath = Path.GetFullPath((Environment.CurrentDirectory + "\\Queue\\"));
if (Directory.Exists(Path.GetFullPath(qpath))) // No need to do Path.GetFullPath again
{
var DirMKV = (Directory.GetFiles(qpath, "*.*", SearchOption.AllDirectories).Where(s => s.EndsWith(".mkv") || s.EndsWith(".mp4")).ToArray()); // no need to do ToArray. List all files in Queue folder
foreach (string file in DirMKV)
{
DirectoryInfo dirinfo = new DirectoryInfo(file); // I don't get any Path not found exception here
if (dirinfo.Parent.Parent.ToString().Contains("S")) // Check if GrandParent directory name contains the letter S. Don't see any such thing in python code
{
string ipath = Environment.CurrentDirectory;
string dpath = ipath + #"\\Queue\\" + dirinfo.Parent.Parent.ToString() + #"\" + Path.GetFileName(file); // Set input file to something like Queue\*S*\File.mkv. Does this file exist??? It should use single backslash instead of double backslash
string opath = ipath + #"\\Finished\\" + dirinfo.Parent.Parent.ToString() + #"\" + Path.GetFileName(file); // Set output file to something like Finished\*S*\File.mkv. It should use single backslash instead of double backslash
string arg = "-i " +dpath + " -o " +opath +" -e x264 "+ " --aencoder ac3 "+ "-s 1 "+ "--subtitle-default 1";
if (!File.Exists(opath))
{
Process.Start(ipath + #"\handbrakeCLI.exe", arg); // does the handbrakeCLI.exe exist in the current directory????
}
}
}
}
Below code is based on my guess about what you want
/*
* Expects a directory structure like below
* S
* |-> bin
* |-> Queue
* |-> test1.mp4
* |-> test2.mkv
* |-> Finished
* |-> test3.mkv
* |-> executable (this code)
* |-> handbrakeCLI.exe
*
*/
DirectoryInfo qpath = new DirectoryInfo("Queue");
if (qpath.Exists) {
var mkvFiles = qpath.GetFiles("*.*", SearchOption.AllDirectories).Where(s => s.Extension == ".mkv" || s.Extension == ".mp4");
foreach (var mkvFile in mkvFiles) {
var gParent = mkvFile.Directory.Parent.ToString();
if (gParent.Contains("S")) {
string opath = Path.Combine(mkvFile.Directory.Parent.FullName, "Finished", mkvFile.Name);
string arg = "-i " + mkvFile.FullName + " -o " + opath + " -e x264 " + " --aencoder ac3 " + "-s 1 " + "--subtitle-default 1";
if (!File.Exists(opath))
Process.Start(Environment.CurrentDirectory+ #"\handbrakeCLI.exe", arg);
}
}
}
I am getting an Exception while running the following PoweShell command:
Get-mailboxPermission -Identity MAILBOX_EMAIL |
fl User,AccessRights,IsInherited,Deny | Out-String -Width 300
Exception:
Exception calling "GetSteppablePipeline" with "1" argument(s): "Cannot find the type for custom attribute 'Parameter'.
Make sure that the assembly that contains this type is loaded."
Followed by this
Get-mailboxPermission -Identity "mailboxidentity" |
fl User,AccessRights,IsInherited,Deny | Out-String -Width 300
Which is getting me a ParameterBindingException
A parameter cannot be found that matches parameter name 'CommandName'.
This is the part of my code:
I will send the above command to executeRemoteCommand function for all the users one by one.
private void initializeRunspace() {
runSpace = RunspaceFactory.CreateRunspace();
runSpace.Open();
createRemotePowershell();
executeRemoteCommand("Set-ExecutionPolicy -ExecutionPolicy RemoteSigned",true);
executeRemoteCommand("Import-PSSession -Session $session -CommandName 'Get-MailboxPermission' ,'Get-MailboxDatabase','Add-ADPermission', 'Get-ADPermission', 'Set-EventLogLevel', 'Get-EventLogLevel'",true);
log("Remote powershell initialization ends");
}
public void createRemotePowershell() {
powershell = PowerShell.Create();
powershell.Runspace = runSpace;
PSCommand rmcommand = new PSCommand();
rmcommand.AddCommand("New-PSSession");
rmcommand.AddParameter("ConfigurationName", "Microsoft.Exchange");
rmcommand.AddParameter("ConnectionUri", uri);
if (creds != null) {
rmcommand.AddParameter("Credential", creds);
}
rmcommand.AddParameter("Authentication", "kerberos");
PSSessionOption sessionOption = new PSSessionOption();
sessionOption.SkipCACheck = true;
sessionOption.SkipCNCheck = true;
sessionOption.SkipRevocationCheck = true;
rmcommand.AddParameter("SessionOption", sessionOption);
powershell.Commands = rmcommand;
Collection<PSSession> result = powershell.Invoke<PSSession>();
log("Remote Powershell Count: "+result.Count);
if (result.Count != 1) {
throw new Exception("Unexpected number of Remote Runspace connections returned.");
}
rmcommand = new PSCommand();
rmcommand.AddCommand("Set-Variable");
rmcommand.AddParameter("Name", "session");
rmcommand.AddParameter("Value", result[0]);
powershell.Commands = rmcommand;
powershell.Invoke();
}
private String executeRemoteCommand(String shellcommand,bool retryOnSessionExpiry) {
try {
if (runSpace == null) {
initializeRunspace();
}
rmcommand = new PSCommand();
rmcommand.AddScript(shellcommand);
rmcommand.Commands.Add("Out-String");
powershell.Commands = rmcommand;
Collection<PSObject> results = powershell.Invoke();
StringBuilder sb = new StringBuilder();
foreach (PSObject obj in results) {
sb.Append(obj.ToString());
}
return sb.ToString();
} catch (CmdletInvocationException ex) {
log("RemotePowershell: CmdletInvocationException - " + shellcommand + " - " +ex.Message);
return "Invalid";
} catch (ParseException ex) {
log("RemotePowershell: ParseException - " + shellcommand + " - " +ex.Message);
return "Invalid";
} catch (ParameterBindingException ex) {
log("RemotePowershell: ParameterBindingException - " + shellcommand + " - " +ex.Message);
return "Invalid";
} catch (CommandNotFoundException ex) {
log("RemotePowershell: CommandNotFoundException - " + shellcommand + " - " +ex.Message);
return "Invalid";
} catch (PSArgumentException ex) {
log("RemotePowershell: PSArgumentException - " + shellcommand + " - " +ex.Message);
return "EMS";
} catch (Exception e) {
if(e.Message.Equals("Unexpected number of Remote Runspace connections returned.")) {
log("remoteShell cannot be established");
return "remoteShell Failed";
} else if(e.Message.Contains("PromptForCredential") && retryOnSessionExpiry) {
log("Session Expired reinitializing runspace");
try {
closeRunSpace();
initializeRunspace();
log("Session Expired runspace reinitialized");
executeRemoteCommand(shellcommand,false);
} catch(Exception ex) {
if(ex.Message.Equals("Unexpected number of Remote Runspace connections returned.")) {
log("Session Expired: remoteShell cannot be established - " + shellcommand + " - " +ex.Message);
closeRunSpace();
return "remoteShell Failed";
}
}
}
log("RemotePowershell: Exception - " + shellcommand + " - " +e.Message);
return "EMSError" + e;
}
}
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I can't seem to get it to work, the only thing that happens is a CMD prompt pops up saying how to use the net function, if you could help me please, i would be grateful.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using System.IO;
namespace Enable_Elevated_Admin
{
class Program
{
static void Main(string[] args)
{
Console.Title = "Enable Admin";
Process enable_admin = new Process();
Process disable_admin = new Process();
enable_admin.StartInfo.Arguments = "user " + "administrator" + "/active:yes";
enable_admin.StartInfo.FileName = #"C:\Windows\System32\net";
disable_admin.StartInfo.Arguments = "user " + "administrator" + "/active:no";
disable_admin.StartInfo.FileName = #"C:\Windows\System32\net";
ConsoleKeyInfo i;
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine("Welcome to ClassyJakey's C# project for enabling the elevated admin easily.");
Console.WriteLine("Options :");
Console.WriteLine("1) Enable elevated admin");
Console.WriteLine("2) Disable elevated admin");
i = Console.ReadKey();
if (i.KeyChar.ToString() == "1")
{
Console.WriteLine("Enabling admin, please wait!");
enable_admin.Start();
Console.WriteLine("Enabled!");
Console.ReadKey();
Console.WriteLine("Creating log...");
StreamWriter writer = new StreamWriter("c:\\log.txt");
writer.WriteLine(System.DateTime.Today);
writer.WriteLine("Enable Admin Log - By ClassyJakey");
writer.WriteLine("Enabling admin was successful!");
writer.WriteLine("If you have errors, please contact classyjakey.");
writer.Close();
}
if (i.KeyChar.ToString() == "2")
{
Console.WriteLine("Disabling admin, please wait!");
disable_admin.Start();
Console.WriteLine("Disabled!");
Console.ReadKey();
StreamWriter writer2 = new StreamWriter("c:\\log2.txt");
writer2.WriteLine(System.DateTime.Today);
writer2.WriteLine("Enable Admin Log - By ClassyJakey");
writer2.WriteLine("Disabling! admin was successful!");
writer2.WriteLine("If you have errors, please contact classyjakey.");
writer2.Close();
}
else
{
Console.WriteLine("You thought you would find a easter egg by not putting 1 or 2?");
Console.WriteLine("Well, your right.");
Console.WriteLine("+ o + o ");
Console.WriteLine(" + o + +");
Console.WriteLine("o + ");
Console.WriteLine(" o + + + ");
Console.WriteLine("+ o o + o");
Console.WriteLine("-_-_-_-_-_-_-_,------, o ");
Console.WriteLine(#"_-_-_-_-_-_-_-| /\_/\ meow ");
Console.WriteLine("-_-_-_-_-_-_-_|__( ^ w^) + +");
Console.WriteLine(#"_-_-_-_-_-_-_- "" "" ");
Console.WriteLine("+ o o + o ");
Console.WriteLine(" + + ");
Console.WriteLine("o o o o +");
Console.WriteLine(" o + ");
Console.WriteLine("+ + o o + ");
StreamWriter writer3 = new StreamWriter("c:\\log3.txt");
writer3.WriteLine(System.DateTime.Today);
writer3.WriteLine("+ o + o ");
writer3.WriteLine(" + o + +");
writer3.WriteLine("o + ");
writer3.WriteLine(" o + + + ");
writer3.WriteLine("+ o o + o");
writer3.WriteLine("-_-_-_-_-_-_-_,------, o ");
writer3.WriteLine(#"_-_-_-_-_-_-_-| /\_/\ meow ");
writer3.WriteLine("-_-_-_-_-_-_-_|__( ^ w^) + +");
writer3.WriteLine(#"_-_-_-_-_-_-_- "" "" ");
writer3.WriteLine("+ o o + o ");
writer3.WriteLine(" + + ");
writer3.WriteLine("o o o o +");
writer3.WriteLine(" o + ");
writer3.WriteLine("+ + o o + ");
writer3.Close();
Console.ReadKey();
}
}
}
}
Probably because you're missing a space to separate the arguments:
enable_admin.StartInfo.Arguments = "user " + "administrator " + "/active:yes";
^----
enable_admin.StartInfo.FileName = #"C:\Windows\System32\net";
disable_admin.StartInfo.Arguments = "user " + "administrator " + "/active:no";
^----
disable_admin.StartInfo.FileName = #"C:\Windows\System32\net";