We help IT Professionals succeed at work.

Remote Desktop

techp
techp asked
on

 i want users to click a batch file (registry) to enable remote desktop rather than going to my computer properties , remote deskop , apply ok etc ..........
Comment
Watch Question

Solution Architect
Commented:
http://www.technize.com/3-ways-to-enable-remote-desktop-in-windows-vista-and-windows-7/

Section 2.

If you need help with creating a script let me know and I can wiff it together for you.

Author

Commented:

 need proper batch file such that it creates automatically by a click
mgrooverSolution Architect

Commented:
Have you got any more background information before I put it together...
What users will be running the script, admin users or standard user?
Are the machines joined to a domain?

Commented:
If the users are not domain or local admins, then they will not be able to change the remote desktop settings by batch file or otherwise.

Why not do it through group policy?

Author

Commented:

 users are in domain users /local adminstrators
mgrooverSolution Architect
Commented:
Use the attached VB-script which was found in Tomislavj's post.

You would still need to have the Window Firewall/3rd party firewall configured to allow connections to RDP.

I would recommend using Group Policy to deploy this to the computers if they are joined to a domain.
'
' -------------------------------------------------
' Turns on Remote Desktop setting
'
' NOTE: Does not configure firewall
'

machine = "."
cimv2_string = "WINMGMTS:" & "\\" & machine & "\root\cimv2"
query = "select * from Win32_TerminalServiceSetting"
value_to_set = 1 ' 0=off, 1=on


set cimv2 = GetObject( cimv2_string )
set items = cimv2.ExecQuery( query )

for each item in items

	item.SetAllowTSConnections( value_to_set )

next
' -------------------------------------------------

Open in new window

Commented:
Okay, why not put the user in the builtin Remote Desktop User group in AD.

If that does not work, why not create a computer group policy (or amend an existing one) that adds a domain security group (create a new security group) to the local Remote Desktop Users group.  

Following a gpupdate /force or reboot it should add this new domain security group to the local Remote Desktop Users group on the machine.

Then you can just add the user to this domain security group and they will be able to access remotely.
Most Valuable Expert 2011
Top Expert 2011
Commented:
Just thought I would add this, where I can do it remotely...... Just launch and enter the Remote PCName..... Simple Input Batch..... (Course you need rights to the target PC). PSEXec is also used to remotely add a user to the target's RDP Group..... Can omit that part if needed, otherwise make sure PSExec is in the path or create the folder structure.....


echo off
setlocal

:begin
cls
	set /p WS=Enter Workstation to enable RDP on:  
	echo.

If exist "c:\BatchFiles\psexec.exe" goto GO

cd\
REM Copies PSExec from the network locally if not present.....
md "BatchFiles"
copy \\server\share\psexec.exe "c:\BatchFiles"


:GO
cls
echo Contacting remote machine....
echo.
echo Note the Value below....
echo.
reg query "\\%ws%\HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server" /v fDenyTSConnections | find /i "fDenyTSConnections"
if %errorlevel%==1 goto again2
echo.
echo 0x1= RDP is Disabled
echo 0x0= RDP is Enabled
echo.
	set /p prmpt=Do you wish to Enable RDP, Disable RDP or Quit? (e, d or q) :  
	echo.

IF %prmpt%==d GOTO DIS
IF %prmpt%==e GOTO MRG
IF %prmpt%==q GOTO end

:DIS
cls
Echo Modifying Registry...
Echo.
reg add "\\%ws%\HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server" /v fDenyTSConnections /t REG_DWORD /d 0x1 /f >nul
pause
GOTO user

:MRG
cls
Echo Modifying Registry...
Echo.
reg add "\\%ws%\HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server" /v fDenyTSConnections /t REG_DWORD /d 0x0 /f >nul
pause
GOTO user

:user
cls
	set /p ASK= Do you wish to add a Remote User on %WS%? (y or n): 

if %ASK%==n goto again
cls
	set /p UID= Enter the UserID to add to Remote Desktop Users Group on %ws%:  
 
REM Change Domain to your domain name.....
"c:\BatchFiles\psexec.exe" \\%WS% net localgroup "Remote Desktop Users" DOMAIN\%UID% /add
cls
	set /p ASK2= Do you wish to open Local Groups on %WS% to verify? (y or n): 

if %ASK2%==n goto again

REM Change Domain to your domain name.....
"C:\WINDOWS\system32\mmc.exe" /s /computer="%ws%.DOMAIN" C:\WINDOWS\system32\lusrmgr.msc

:again
cls
	set /p ASK2=Do you wish to enable another RDP on another workstation (y or n)? 
	echo.

if %ask2%==y goto begin
if %ask2%==n goto end

:again2
cls
echo There was a problem contacting the machine. Please check that it is online.
echo.
pause

goto end

:END
endlocal
echo Goodbye!!

ping -n 5 localhost >nul


exit

Open in new window

Author

Commented:

 none of them had given exact answer
 ( i want users to click a batch file (registry) to enable remote desktop rather than going to my computer properties , remote deskop , apply ok etc .)
Most Valuable Expert 2011
Top Expert 2011

Commented:
Thats exactly what I posted.... I use it for remote PC's, but you could easily enter localhost

Here it is in its most simple format....
echo off  
setlocal  
  
:begin  
cls  
        set /p WS=Enter Workstation to enable RDP on:    
        echo.  
  
:MRG  
cls  
Echo Modifying Registry...  
Echo.  
reg add "HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server" /v fDenyTSConnections /t REG_DWORD /d 0x0 /f >nul && echo RDP is now enabled....
echo.
pause
  
:END  
endlocal  
echo Goodbye!!  
  
ping -n 5 localhost >nul  
  
  
exit

Open in new window