Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 467 Vote(s) - 3.51 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Run command line code programmatically using C#

#1
I'm using this code run in windows command prompt..
But I need this done programmatically using C# code

>C:\Windows\Microsoft.NET\Framework\v4.0.30319>aspnet_regiis.exe -pdf "connection
Strings" "C:\Users\XXX\Desktop\connection string\DNN"
Reply

#2
You may use the [`Process.Start`][1] method:

Process.Start(
@"C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_regiis.exe",
@"-pdf ""connection Strings"" ""C:\Users\XXX\Desktop\connection string\DNN"""
);

or if you want more control over the shell and be able to capture for example the standard output and error you could use [`the overload`][2] taking a `ProcessStartInfo`:

var psi = new ProcessStartInfo(@"C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_regiis.exe")
{
Arguments = @"-pdf ""connection Strings"" ""C:\Users\XXX\Desktop\connection string\DNN""",
UseShellExecute = false,
CreateNoWindow = true
};
Process.Start(psi);


[1]:

[To see links please register here]

[2]:

[To see links please register here]

Reply

#3
You should be able to do that using a process

var proc = new Process();
proc.StartInfo.FileName = @"C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_regiis.exe ";
proc.StartInfo.Arguments = string.Format(@"{0} ""{1}""" ""{2}""","-pdf","connection Strings" ,"C:\Users\XXX\Desktop\connection string\DNN");
proc.StartInfo.UseShellExecute = false;
proc.StartInfo.RedirectStandardOutput = true;
proc.Start();
string outPut = proc.StandardOutput.ReadToEnd();

proc.WaitForExit();
var exitCode = proc.ExitCode;
proc.Close();
Reply

#4
try this

ExecuteCommand("Your command here");

call it using process

public void ExecuteCommand(string Command)
{
ProcessStartInfo ProcessInfo;
Process Process;

ProcessInfo = new ProcessStartInfo("cmd.exe", "/K " + Command);
ProcessInfo.CreateNoWindow = true;
ProcessInfo.UseShellExecute = true;

Process = Process.Start(ProcessInfo);
}
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through