Returning C# results

PHaRTnONu

Client
Регистрация
01.10.2016
Сообщения
340
Благодарностей
48
Баллы
28
i am having the worst time at the moment, i dont know wtf im doing wrong and my head is killing me


C#:
Process P = Process.Start(C:\Program Files\Stringing\stringy.exe, -filename E:\RAW\project.Variablese.FileName -metaJSON E:\RAW\project.Variables.UID.json -thumbnail E:\RAW\project.Variables.Image);
P.WaitForExit();
int result = P.ExitCode;
99787


all i get back are errors. IDK wtf im doing wrong here.......
Can some one please explain this to me
im trying to get back the results of a command line exicution i KNOW and tested its works correctly......
i just need the results
 

PHaRTnONu

Client
Регистрация
01.10.2016
Сообщения
340
Благодарностей
48
Баллы
28
I added @""
C#:
Process P = Process.Start(@"C:\Program Files\Stringing\stringy.exe", @"-filename E:\RAW\project.Variablese.FileName -metaJSON E:\RAW\project.Variables.UID.json -thumbnail E:\RAW\project.Variables.Image");
P.WaitForExit();
int result = P.ExitCode;
but now im getting this
99788
 

BAZAg

Client
Регистрация
08.11.2015
Сообщения
1 761
Благодарностей
2 401
Баллы
113
Perhaps if you just submit a string - it will not work. I didn't check.
C#:
string program = @"""C:\Program Files\Stringing\stringy.exe""";
string filename = Path.Combine(@"E:\RAW", project.Variables["FileName"].Value);
string metaJSON = Path.Combine(@"E:\RAW", project.Variables.UID.json); // json variable
string thumbnail = Path.Combine(@"E:\RAW", project.Variables["Image"].Value);
List<string[]> list = new List<string[]>();

list.Add(new[]{"-filename",string.Format(@"""{0}""", filename) });
list.Add(new[]{"-metaJSON",string.Format(@"""{0}""", metaJSON) });
list.Add(new[]{"-thumbnail",string.Format(@"""{0}""", thumbnail) });

string line = string.Join(", ", new[]{program, string.Join(" ", list.Select(x=> string.Join(" ", x)))});
// return line; // arguments line

Process P = Process.Start(line);
P.WaitForExit();
int result = P.ExitCode;

The second example below is more like a working example.
C#:
string program = @"""C:\Program Files\Stringing\stringy.exe""";
string filename = Path.Combine(@"E:\RAW", project.Variables["FileName"].Value);
string metaJSON = Path.Combine(@"E:\RAW", project.Variables.UID.json); // json variable
string thumbnail = Path.Combine(@"E:\RAW", project.Variables["Image"].Value);
List<string[]> list = new List<string[]>();

list.Add(new[]{"-filename",string.Format(@"""{0}""", filename) });
list.Add(new[]{"-metaJSON",string.Format(@"""{0}""", metaJSON) });
list.Add(new[]{"-thumbnail",string.Format(@"""{0}""", thumbnail) });

//string line = string.Join(", ", new[]{program, string.Join(" ", list.Select(x=> string.Join(" ", x)))});
// return line; // arguments line


Process process = new Process();
process.StartInfo.FileName = program;
process.StartInfo.Arguments = string.Join(" ", list.Select(x=> string.Join(" ", x)));
process.StartInfo.Verb = "runas"; // admin
process.StartInfo.CreateNoWindow = false;// window hide
process.Start();    
process.WaitForExit();
 
Последнее редактирование:
  • Спасибо
Реакции: Phoenix78

PHaRTnONu

Client
Регистрация
01.10.2016
Сообщения
340
Благодарностей
48
Баллы
28
this didnt work? am i able to pass a value through this?


Perhaps if you just submit a string - it will not work. I didn't check.
C#:
string program = @"""C:\Program Files\Stringing\stringy.exe""";
string filename = Path.Combine(@"E:\RAW", project.Variables["FileName"].Value);
string metaJSON = Path.Combine(@"E:\RAW", project.Variables.UID.json); // json variable
string thumbnail = Path.Combine(@"E:\RAW", project.Variables["Image"].Value);
List<string[]> list = new List<string[]>();

list.Add(new[]{"-filename",string.Format(@"""{0}""", filename) });
list.Add(new[]{"-metaJSON",string.Format(@"""{0}""", metaJSON) });
list.Add(new[]{"-thumbnail",string.Format(@"""{0}""", thumbnail) });

string line = string.Join(", ", new[]{program, string.Join(" ", list.Select(x=> string.Join(" ", x)))});
// return line; // arguments line

Process P = Process.Start(line);
P.WaitForExit();
int result = P.ExitCode;

The second example below is more like a working example.
C#:
string program = @"""C:\Program Files\Stringing\stringy.exe""";
string filename = Path.Combine(@"E:\RAW", project.Variables["FileName"].Value);
string metaJSON = Path.Combine(@"E:\RAW", project.Variables.UID.json); // json variable
string thumbnail = Path.Combine(@"E:\RAW", project.Variables["Image"].Value);
List<string[]> list = new List<string[]>();

list.Add(new[]{"-filename",string.Format(@"""{0}""", filename) });
list.Add(new[]{"-metaJSON",string.Format(@"""{0}""", metaJSON) });
list.Add(new[]{"-thumbnail",string.Format(@"""{0}""", thumbnail) });

//string line = string.Join(", ", new[]{program, string.Join(" ", list.Select(x=> string.Join(" ", x)))});
// return line; // arguments line


Process process = new Process();
process.StartInfo.FileName = program;
process.StartInfo.Arguments = string.Join(" ", list.Select(x=> string.Join(" ", x)));
process.StartInfo.Verb = "runas"; // admin
process.StartInfo.CreateNoWindow = false;// window hide
process.Start();  
process.WaitForExit();
99791
 

Вложения

Последнее редактирование:

BAZAg

Client
Регистрация
08.11.2015
Сообщения
1 761
Благодарностей
2 401
Баллы
113
this didnt work? am i able to pass a value through this?





:/
This i though would work
{-Variable.UID-}
was just supposed to have a .json on the end of that variable.
i tried setting the variable {-Variable.Json-} Посмотреть вложение 99789
and
string metaJSON = Path.Combine(@"E:\RAW", project.Variables.["Json"].Value);

but im getting
Посмотреть вложение 99790
Run in a new template. Perhaps the error is in another cube.

Good line.
This line contains no errors.
string metaJSON = Path.Combine(@"E:\RAW", project.Variables["Json"].Value);

Yes ERROR - DOT before ["Json"]

string metaJSON = Path.Combine(@"E:\RAW", project.Variables.["Json"].Value);
Show the topmost error in the log.
Before execution, clear the log.
 
Последнее редактирование:

PHaRTnONu

Client
Регистрация
01.10.2016
Сообщения
340
Благодарностей
48
Баллы
28
Run in a new template. Perhaps the error is in another cube.

Good line.
This line contains no errors.
string metaJSON = Path.Combine(@"E:\RAW", project.Variables["Json"].Value);

Yes ERROR - DOT before ["Json"]

string metaJSON = Path.Combine(@"E:\RAW", project.Variables.["Json"].Value);
Show the topmost error in the log.
Before execution, clear the log.
it was the . Right after . Variables
removed it now have this error


Compiling code of Error in action "CS0246" "The type or namespace name 'Process' could not be found (are you missing a using directive or an assembly reference?)". [Row: 15; Column: 1]
99792
 

BAZAg

Client
Регистрация
08.11.2015
Сообщения
1 761
Благодарностей
2 401
Баллы
113
it was the . Right after . Variables
removed it now have this error


Compiling code of Error in action "CS0246" "The type or namespace name 'Process' could not be found (are you missing a using directive or an assembly reference?)". [Row: 15; Column: 1]
Посмотреть вложение 99792
The error message says that you did not add using.
Try adding the full path like this:
C#:
// Process process = new Process();
System.Diagnostics.Process process = new System.Diagnostics.Process();
 

PHaRTnONu

Client
Регистрация
01.10.2016
Сообщения
340
Благодарностей
48
Баллы
28
The error message says that you did not add using.
Try adding the full path like this:
C#:
// Process process = new Process();
System.Diagnostics.Process process = new System.Diagnostics.Process();
that worked, except im just getting the return of "ok" which isnt the return value the cmd is supposed to give a result
 

BAZAg

Client
Регистрация
08.11.2015
Сообщения
1 761
Благодарностей
2 401
Баллы
113
that worked, except im just getting the return of "ok" which isnt the return value the cmd is supposed to give a result
C#:
string program = @"""C:\Program Files\Stringing\stringy.exe""";
string filename = Path.Combine(@"E:\RAW", project.Variables["FileName"].Value);
string metaJSON = Path.Combine(@"E:\RAW", project.Variables["Json"].Value);
string thumbnail = Path.Combine(@"E:\RAW", project.Variables["Image"].Value);

var list = new List<string[]>();
    list.Add(new[]{"-filename",string.Format(@"""{0}""", filename) });
    list.Add(new[]{"-metaJSON",string.Format(@"""{0}""", metaJSON) });
    list.Add(new[]{"-thumbnail",string.Format(@"""{0}""", thumbnail) });


string out_line = string.Empty;
try {
    var p = new System.Diagnostics.Process();
    p.StartInfo.RedirectStandardError = true;
    p.StartInfo.RedirectStandardOutput = true;
    p.StartInfo.UseShellExecute = false;
    p.StartInfo.CreateNoWindow = true;
    p.StartInfo.Verb = "runas";
    p.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
    p.StartInfo.FileName = program; // path program
    p.StartInfo.Arguments = string.Join(" ", list.Select(x=> string.Join(" ", x))); // args
    p.OutputDataReceived += new System.Diagnostics.DataReceivedEventHandler((sender, e) => {
        if(!string.IsNullOrEmpty(e.Data)){
            out_line = e.Data;
        }
    });
    p.ErrorDataReceived += new System.Diagnostics.DataReceivedEventHandler((sender, e) => {
        if(!string.IsNullOrEmpty(e.Data)){
            out_line = e.Data;
        }
    });
    p.Start();
    p.BeginOutputReadLine();
    p.BeginErrorReadLine();
    p.WaitForExit();
}
catch (Exception e){
    out_line = e.Message;
}

return out_line;
 
  • Спасибо
Реакции: PHaRTnONu

PHaRTnONu

Client
Регистрация
01.10.2016
Сообщения
340
Благодарностей
48
Баллы
28
C#:
string program = @"""C:\Program Files\Stringing\stringy.exe""";
string filename = Path.Combine(@"E:\RAW", project.Variables["FileName"].Value);
string metaJSON = Path.Combine(@"E:\RAW", project.Variables["Json"].Value);
string thumbnail = Path.Combine(@"E:\RAW", project.Variables["Image"].Value);

var list = new List<string[]>();
    list.Add(new[]{"-filename",string.Format(@"""{0}""", filename) });
    list.Add(new[]{"-metaJSON",string.Format(@"""{0}""", metaJSON) });
    list.Add(new[]{"-thumbnail",string.Format(@"""{0}""", thumbnail) });


string out_line = string.Empty;
try {
    var p = new System.Diagnostics.Process();
    p.StartInfo.RedirectStandardError = true;
    p.StartInfo.RedirectStandardOutput = true;
    p.StartInfo.UseShellExecute = false;
    p.StartInfo.CreateNoWindow = true;
    p.StartInfo.Verb = "runas";
    p.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
    p.StartInfo.FileName = program; // path program
    p.StartInfo.Arguments = string.Join(" ", list.Select(x=> string.Join(" ", x))); // args
    p.OutputDataReceived += new System.Diagnostics.DataReceivedEventHandler((sender, e) => {
        if(!string.IsNullOrEmpty(e.Data)){
            out_line = e.Data;
        }
    });
    p.ErrorDataReceived += new System.Diagnostics.DataReceivedEventHandler((sender, e) => {
        if(!string.IsNullOrEmpty(e.Data)){
            out_line = e.Data;
        }
    });
    p.Start();
    p.BeginOutputReadLine();
    p.BeginErrorReadLine();
    p.WaitForExit();
}
catch (Exception e){
    out_line = e.Message;
}

return out_line;

api hit its daily capp....... so i dont know if it is working, i think it might be. ill have to wait till tomarrow to see
 

Кто просматривает тему: (Всего: 2, Пользователи: 0, Гости: 2)