Hello, how can I make a program respond to another program's input request?
For example, this code:
Process.Start("unrar.exe", "e D:\temp\key.rar D:temp2")
SendKeys.SendWait("test~")
will successfully start a program that prompts for a password, and then
submit the password via SendKeys. SendKeys will work with both console and
windows prompts. However, the program only works when is executed by
someone currently logged on in the computer. If you schedule the program to
run when nobody is logged on, the program will fail, I think, because now
window is displayed for the SendKeys function to send the password. This is
the error the program logs when this happen:
System.Security.SecurityException: Unable to create Hook.
at System.Windows.Forms.SendKeys.InstallHook()
at System.Windows.Forms.SendKeys.Send(String keys, Control control,
Boolean wait)
etc, etc,
I also tried with RedirectStandardInput (code below), but this did not work
at all.
Dim p As New Process
p.StartInfo.FileName = "unrar.exe"
p.StartInfo.Arguments = "e D:\temp\key.rar D:\temp2"
p.StartInfo.UseShellExecute = False
p.StartInfo.RedirectStandardInput = True
p.Start()
p.StandardInput.WriteLine("test")
p.StandardInput.Close()
p.WaitForExit()
p.Close()
This code does not cause an error, but the program replies that an incorrect
password was entered.
Could anyone please help, I need to be able to start a program at boot time.
The program requires a password, but does not provide a command line option
for it.
Any help will be greatly appreciated.
federico