如何通过 telnet 启动我的 winforms 应用程序?
我在客户端计算机上有一个 Windows 窗体应用程序。 我正在尝试通过 telnet 登录,关闭它,更新一些文件,然后重新启动它。
在客户端计算机上使用 cmd 并输入 MyApp.exe 可以很好地启动它。 但是,如果我在 telnet 窗口中执行此操作,则会发生一些奇怪的情况:应用程序在进程列表中的当前位置启动,但它的任何表单都没有打开,也没有完成任何 log4net 日志记录。
这是怎么回事?我该如何解决这个问题?
编辑:所有基于表单的 Windows 应用程序似乎都是这种情况。 自己尝试一下:telnet localhost => 记事本。 它会在用户界面中弹出,但不会在用户界面中弹出!
另外,我在所有这些计算机上都安装了 RAdmin 吗? 据我所知,它的自动化设施并不存在,但也许它有什么可以帮助我的?
I have a windows forms application on a client machine. I am trying to log in via telnet, shut it down, update some files, and restart it.
Using cmd on the client machine and typing in MyApp.exe works great to start it. But if I do this in the telnet window something odd happens: The application starts in as far as it is now in the process list but none of its forms ever open nor any log4net logging is done.
What's going on and how do I fix this?
Edit: This seems to be the case with all form-based windows apps. Try it out yourself: telnet localhost => notepad. It pops up int he user interface but not the ui!
Also, I have RAdmin installed on all these machines? From what I've seen its got non-existent automation facilities but maybe there's something about it that can help me out?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
编辑:在我原来的回答中,我误解了你的问题,我以为你说你重新启动了机器。
话虽如此,我仍然可能会尝试采取不同的方法。 您可以在 MyApp.exe 中设置某种类型的自动更新服务吗? 一种简单的方法是设置一个 Web 服务,MyApp.exe 可以轮询该服务以查看新版本何时可用。 然后您需要启动更新程序应用程序来完成更新工作。
Edit: In my original answer, I misunderstood your question, I thought you said you restarted the machine.
With that said, I'd still probably try to take a different approach. Can you set some type of auto update service into MyApp.exe. An easy way would be to set up a webservice which MyApp.exe can poll to see when new versions are available. Then you'll need to lauch an updater application to do the updating work.
您可以尝试使用 VNCRobot,而不是使用 telnet。 我相信 VNCRobot 作为用户运行并且应该共享相同的桌面。
免责声明:我从未使用过 VNCRobot,我只是认为它值得一提。
Instead of using telnet, you could try using VNCRobot. I believe VNCRobot runs as the user and should share the same desktop.
Disclaimer: I've never used VNCRobot, I just thought it would be worth mentioning.
我认为发生的情况是您的应用程序在私人桌面上启动,然后在您关闭 telnet 会话后立即退出。 我不知道如何让它在“当前/活动”桌面窗口上启动,但要在注销 telnet 后保持它运行,请尝试使用“
start
”命令运行。I think what's going on is that your app is starting up on a private desktop, and then quiting as soon as you close your telnet session. I don't know how to make it start up on the "current/active" desktop window, but to keep it running after you log out of telnet try running with the "
start
" command.在 Windows XP 上,我通过使用 Windows 任务计划程序找到了解决此限制的方法。 对于 Windows 7,默认情况下不安装 telnet。
我首先必须通过合并以下注册表设置将本地帐户的网络访问:共享和安全模型更改为“经典 - 本地用户以自己的身份进行身份验证”:
Windows 注册表编辑器版本 5.00
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa]
"forceguest"=dword:00000000
我将它放在远程 FTP 服务器上的文件中,并使用 FTP 命令获取它。
将其与 regedit /s file.reg 合并
然后我创建了一个运行一次的任务:
SchTasks /Create /SC ONCE /RU "user" /RP pass /TN "StartApp" /TR "\"C:\Windows\NotePad.exe\"" /ST 00:00:00
手动启动计划:
Schtasks /run /tn "StartApp"
删除了计划:
schtasks /delete /F /tn "StartAPP"
这有效。 疯狂吧! 多么痛苦啊!
On Windows XP, I found a way around this limitation by using Windows task scheduler. For Windows 7, telnet is not installed by default.
I first had to change the Network Access: Sharing and security model for local accounts to "Classic – local users authenticate as themselves" by merging the following registry settings:
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa]
"forceguest"=dword:00000000
I placed it in a file on a remote FTP server and used the FTP command to get it.
Merge it with regedit /s file.reg
Then I created a task that ran once:
SchTasks /Create /SC ONCE /RU "user" /RP pass /TN "StartApp" /TR "\"C:\Windows\NotePad.exe\"" /ST 00:00:00
Manually started the schedule:
Schtasks /run /tn "StartApp"
Deleted the schedule:
schtasks /delete /F /tn "StartAPP"
And that worked. Crazy right! What a pain!
如果您可以在这些计算机上运行 PowerShell,您可以使用它来查找正在运行的进程并终止它。 ..
..Cmdlet 将向您显示正在运行的进程,您可以通过此列表编写 foreach 逻辑,并直接在 powershell 中将您的应用程序与正则表达式匹配,我不了解 Ruby,但理论上您可以使用它来执行相同的调用powershell 命令为:
终止进程:
不太确定如何通过 telnet 启动 GUI 进程,我的设备上没有 telnet 设置。
也许你可以做类似的事情: http://www.peterprovost.org/blog/post/Powershell-Sudo-(sort-of)-for-Vista-UAC.aspx
将动词设置为“runas”,如示例所示该地址将调用 UAC,这样做我无法杀死新进程,但是如果我设置:
另外,您也可以设置这些属性:
If you can run PowerShell on these machines you could use it to find the running process and kill it. the..
..Cmdlet will show you the running processes, you can write the logic to foreach through this list and match your application with regex directly in powershell, I don't know Ruby but theoretically you could use it to do the same invoking the powershell commands with:
To kill a process its:
Not quite sure how to start the GUI process through telnet, I don't have telnet setup on my equipment.
perhaps you can do something similar to this: http://www.peterprovost.org/blog/post/Powershell-Sudo-(sort-of)-for-Vista-UAC.aspx
Setting the verb to "runas" like in the example at that address will invoke UAC, doing this I was unable to kill the new process, however I am to kill it if I set:
Additionally you can set these attributes as well: