如何以编程方式启用远程桌面连接? [英] How to enable Remote Desktop Connection Programmatically?

查看:71
本文介绍了如何以编程方式启用远程桌面连接?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建一个小的应用程序来设置新的Windows 7系统.从本质上讲,这样我可以在所有设置完好无损的情况下制作硬盘驱动器的映像.

I'm trying to create a small application to setup fresh windows 7 systems. This is essentially so I can make images of the hard drives with all of the settings intact.

如何从C#启用远程桌面?

How would I go about enabling remote desktop from C# ?

我觉得很有趣,每个人都在激怒我,但没人回答这个问题,sysprep无法执行设置映像所需的所有必需操作.我要启用RDP而不运行它.我只是更改注册表项并添加防火墙设置.

I find it funny that everyone is flamming me but no one anwsered the question, sysprep cant do all of the required actions that I need in setting up the image. I want to enable RDP not run it. I will just change the registry key and add a firewall setting.

我将需要此映像在多个硬件上执行.

I will need this image to perform on several pieces of hardware.

这是我需要完成的任务清单.

Here is the laundry list of tasks I need to complete.

静态IP地址,取决于计算机.更改文件夹权限,取决于域.变更电脑名称安装Rysnc服务器安装自定义应用程序安装自定义服务防火墙权限车手禁用交互式登录更改日期时间取决于要发送系统的位置激活Windows组策略设置.

Static IP address, depends on computer. Change Folder Permissions, depends on Domain. Change Computer Name Install Rysnc Server Install Custom Applications Install Custom Services Firewall Permissions Drivers Disable Interactive Logon Change Date Time Depending on Location for System to be Sent Activate Windows Group Policy Settings.

我不认为sysprep可以做所有这些事情吗?

I dont think that sysprep can do all these things can it?

推荐答案

我在上一个项目中使用了以下内容,并且似乎运行良好:

I've used the following in a previous project and it seems to work well:

        try
        {
            RegistryKey key = RegistryKey.OpenRemoteBaseKey(RegistryHive.LocalMachine, TargetMachine.Name);
            key = key.OpenSubKey(@"SYSTEM\CurrentControlSet\Control\Terminal Server", true);
            object val = key.GetValue("fDenyTSConnections");
            bool state = (int)val != 0;
            if (state)
            {
                key.SetValue("fDenyTSConnections", 0, RegistryValueKind.DWord);
                MessageBox.Show("Remote Desktop is now ENABLED");
            }
            else
            {
                key.SetValue("fDenyTSConnections", 1, RegistryValueKind.DWord);
                MessageBox.Show("Remote Desktop is now DISABLED");
            }
            key.Flush();
            if (key != null)
                key.Close();
        }
        catch
        {
            MessageBox.Show("Error toggling Remote Desktop permissions");
        }

这篇关于如何以编程方式启用远程桌面连接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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