Enter password in command prompt on fly -


i have problem here.

        string strdir = @"cd /d d:\dirc";         string strcmd = @"gpg --output d:\dirop\outputfile.txt --decrypt d:\dirip\encfile.enc";           string strpass = thewcf.getpassphrase(); \\which return string value.          process pr;         processstartinfo args = new processstartinfo("cmd.exe");           args.redirectstandardinput = true;         args.redirectstandardoutput = true;         args.useshellexecute = false;         args.windowstyle = processwindowstyle.normal;         pr = process.start(args);          pr.standardinput.writeline(strdir);         application.doevents();         thread.sleep(1000);         application.doevents();          pr.standardinput.writeline(strcmd);         application.doevents();         thread.sleep(1000);         application.doevents(); 

upto here ok @ point cmd prompt asks passphrase... how pass passphrase here code behind (passphrase service cant hardcode) example:

 string strpassphrase=thewcf.getpassphrase(); 

how pass strpassphrase command prompt? please suggest way in advance

this may obvious, have tried

pr.standardinput.writeline(strpassphrase); 

from microsoft msdn page:

a process can read input text standard input stream, typically keyboard. redirecting standardinput stream, can programmatically specify input. example, instead of using keyboard input, can provide text contents of designated file or output application. ref: http://msdn.microsoft.com/en-us/library/system.diagnostics.process.standardinput.aspx

actually, seems it's want... in example (slightly modified reference linked above):

dim mystreamwriter streamwriter = pr.standardinput       ' prompt user input text lines sort.        ' write each line standardinput stream of       ' sort command.       dim inputtext string       dim numlines integer = 0         pr.writeline("enter line of text (or press enter key stop):")         inputtext = pr.standardinput.readline()         if inputtext.length > 0            numlines += 1            mystreamwriter.writeline(inputtext)         end if       loop while inputtext.length <> 0 

Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -