从无人参与的过程向提示提供值 [英] Supply a value to the prompt from an unattended process

查看:46
本文介绍了从无人参与的过程向提示提供值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好
我有一个用C#编写的Windows服务
它使用一些参数调用exe.但是,其中一个参数是提示.

Hello
I have a windows service written in c#
it calls an exe with some arguments. However one of the arguments is a prompt.

我无法从Windows服务中提示用户,但可以发送提示值"有代码吗?

I cant prompt a user from a windows service but can I send in "prompt values" with code?

我已经尝试过了:

            Process myProcess = new Process();
            ProcessStartInfo startInfo =新的ProcessStartInfo();           
            startInfo.FileName ="C:\\ Windows \\ System32 \\ tpmvscmgr.exe";
            startInfo.Arguments =创建/名称tpmvsc/pin提示/adminkey随机/generate";            
            startInfo.RedirectStandardInput = true;
       
            startInfo.UseShellExecute = false;          
            myProcess.StartInfo = startInfo;
            myProcess.Start(); 
      
            System.IO.StreamWriter myStreamWriter = myProcess.StandardInput;

            System.Threading.Thread.Sleep(5700); //或while(true)

            myStreamWriter.WriteLine("12345678");

           Process myProcess = new Process();
            ProcessStartInfo startInfo = new ProcessStartInfo();           
            startInfo.FileName = "C:\\Windows\\System32\\tpmvscmgr.exe";
            startInfo.Arguments = "create /name tpmvsc /pin prompt /adminkey random /generate";            
            startInfo.RedirectStandardInput = true;
       
            startInfo.UseShellExecute = false;          
            myProcess.StartInfo = startInfo;
            myProcess.Start(); 
      
            System.IO.StreamWriter myStreamWriter = myProcess.StandardInput;

            System.Threading.Thread.Sleep(5700); //or while(true)

            myStreamWriter.WriteLine("12345678");

但是它不起作用.没有添加任何输入.
有什么建议吗?

It does not work however. there is no input added.
Any advice?

推荐答案

但是它不起作用.没有添加任何输入.
有什么建议吗?

除了重写其他程序以不提示用户外,您无能为力.

There is nothing you can do other than rewrite the other program to not prompt the user.


这篇关于从无人参与的过程向提示提供值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆