Enable Remote Desktop and open the firewall for Remote Desktop using psexec

 Sure, here's an example script that you can use to enable Remote Desktop and open the firewall for Remote Desktop using psexec:


```

@echo off


set /p hostname="Enter the hostname or IP address of the remote computer: "


echo Enabling Remote Desktop...

psexec \\%hostname% reg add "HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server" /v fDenyTSConnections /t REG_DWORD /d 0 /f


echo Opening Firewall for Remote Desktop...

psexec \\%hostname% netsh advfirewall firewall set rule group="remote desktop" new enable=yes


pause

```


To run this script as an administrator, you can do the following:


1. Copy and paste into a Notepad file and save it as Enable_RDP.bat.

2. Right-click on the script file and select "Run as administrator".

2. If you are running the script from the command prompt, you can open an elevated command prompt by right-clicking on the Command Prompt shortcut and selecting "Run as administrator", and then navigate to the directory where the script is located and run it from there.

Comments

Popular posts from this blog

Clearing DNS cache on vCenter Server Appliance

Repairing a virtual disk in Workstation (2019259)