远程注册表调用和打开套接字` [英] Remote Registry Call and Open Socket`

查看:58
本文介绍了远程注册表调用和打开套接字`的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近整理了一个实用程序,以方便本地网络上的一些更改......简而言之,我必须远程编辑所选工作站的注册表,然后运行第三方EXE(本地)传递工作站名称作为参数来完成我的过程。

I recently put together a utility to facilitate some changes on a local network... Long story short, I have to remotely edit the registry of selected workstations, then run a third party EXE (locally) passing in a workstation name as a parameter to complete my process.

从应用程序的角度来看,每个组件都可以完美地工作......独立...远程注册表HACK使用RegistryKey和OpenRemoteBaseKey按预期工作并记录。然后我为EXE编写了一个进程处理程序......这只是使用ProcessStartInfo创建一个本地进程,我将输出重定向到StreamWriter以捕获第三方EXE吐出的内容"如果在命令提示符下执行"。同样,这件作品按预期工作。我遇到的问题有点简单......当我在我的应用程序中组合这两个函数时,我收到来自EXE的错误,它告诉我"同一个用户与服务器或共享资源的多个连接,使用多个用户姓名,不允许。断开之前与服务器或共享资源的所有连接,然后重试.."

From the perspective of the application each component works flawlessly... independantly... The remote registry HACK using RegistryKey and OpenRemoteBaseKey and works as expected and documented. I then wrote a process handler for the EXE... This simply creates a local process using ProcessStartInfo and I redirect the output to a StreamWriter to capture what the third party EXE spits out "if executed at a command prompt". Again, this piece works as expected. The problem that I have is somewhat simple... When I combine these two functions in my application I receive an error from the EXE that tells me "Multiple connections to a server or shared resource by the same user, using more than one user name, are not allowed. Disconnect all previous connections to the server or shared resource and try again.."

我明白了什么问题是... RegistryKey和OpenRemoteBaseKey在客户端(我的应用程序)和服务器(远程机器)之间创建一个套接字。然后,即使在我努力使用应用程序中的Registry组件的Close()和Dispose()之后,它仍会保持打开状态一段时间。然后,当我启动我的可执行文件时,它发出错误告诉我你正试图连接到同一个资源两次......这就是问题了......我如何在EXE之前杀死连接,或者等待直到该连接关闭...是否有可以在注册表连接上设置的超时期限?

I understand what the problem is... RegistryKey and OpenRemoteBaseKey create a socket between the client (my app) and the server (the remote machine). It is then held open for some timeout period even after I diligently Close() and Dispose() of the Registry components in the application. Then as I kick off my executable it bails out with an error telling me that you are trying to connect to the same resouce twice... Here is the question then... How do I either Kill the connection before the EXE, or WAIT until that connection is closed... Is there a timeout period that I can set on the registry connection?

任何帮助都将不胜感激。

Any assistance would be appreciated.

推荐答案

你是一次做一台机器(注册表后跟exe),还是一台机器的多台机器?您传递给Process.Start的参数是什么,是否包含凭据?


这篇关于远程注册表调用和打开套接字`的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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