Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


change remote desktop settings

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,25309
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> change remote desktop settings
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 change remote desktop settings - 8/27/2005 12:28:07 PM   
  the_apostle21


Posts: 54
Score: 0
Joined: 7/29/2005
Status: offline
Hello all,

i need a script to be able to do the folowing things:

* Enable remote desktop locally.
* enable a particular user to connect remotely.
* change the local password of a particular user.

does anyone know if these can be done, and if so, does anyone have any code for it?

thanks in advance...
 
 
Post #: 1
 
 RE: change remote desktop settings - 8/27/2005 2:58:34 PM   
  mbouchard


Posts: 1916
Score: 16
Joined: 5/15/2003
From: USA
Status: offline
quote:


* Enable remote desktop locally.

This is possible, but would require a reboot as it is done with a reg change, I have some code that I have been working on, but it is at work, will post it on Monday.
quote:


* enable a particular user to connect remotely.

Easiest way, add a user to local admin and or remote desktop users, look at the script center link to see an example of adding a user to a group.

quote:


* change the local password of a particular user.

Check script center.

_____________________________

Mike

For useful Scripting links see the Read Me First stickey!

Always remember Search is your friend.

(in reply to the_apostle21)
 
 
Post #: 2
 
 RE: change remote desktop settings - 8/27/2005 6:27:20 PM   
  the_apostle21


Posts: 54
Score: 0
Joined: 7/29/2005
Status: offline
Hi mbouchard,

thanks for your reply.  Any code that can help my cause will be greatly appreciated.

It makes sense what you say about adding a user to RDP users...but excuse my 'newbie' side, but what is the script center?

thanks again.

(in reply to mbouchard)
 
 
Post #: 3
 
 RE: change remote desktop settings - 8/27/2005 11:08:07 PM   
  mbouchard


Posts: 1916
Score: 16
Joined: 5/15/2003
From: USA
Status: offline
Look in my Sig or in the pinned post.  You will find many useful links there.

_____________________________

Mike

For useful Scripting links see the Read Me First stickey!

Always remember Search is your friend.

(in reply to the_apostle21)
 
 
Post #: 4
 
 RE: change remote desktop settings - 8/28/2005 10:34:55 PM   
  mbouchard


Posts: 1916
Score: 16
Joined: 5/15/2003
From: USA
Status: offline
This is a work in progress so there may be some errors that I have not seen yet, also, it is not commented yet.

Const HKEY_LOCAL_MACHINE = &H80000002
Dim strKeyPath,strValueName,dwValue,strValue
Dim doReboot,oReg,CheckKey,strComputer, ret
Dim WshShell : Set WshShell = WScript.CreateObject("WScript.Shell")

strKeyPath = "SYSTEM\CurrentControlSet\Control\Terminal Server"
strValueName = "fDenyTSConnections"
dwValue = 0

'1 = Disabled
'0 = Enabled

ret = InputBox("Type in Computer name that you wish to enable Remote Desktop Connection on." & vbcr _
& vbcr & "Click cancel if you want to do it on the Local PC.","Enable Remote Desktop Connection","LOCAL")

If TypeName(Ret) = "Empty" Then
    WshShell.Popup "Quitting Script" & vbCr & "This window will close in 10 seconds",10
    Wscript.Quit
ElseIf ret = "LOCAL" then
    strComputer = "."
Else
    strComputer = ret
End If
'msgbox strComputer
'wscript.quit
On Error Resume Next
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv")
If Not err.Number = 0 then
    msgbox err.description
    wscript.quit
End If
On error goto 0
'Check if key exists 0=Yes 1=No
CheckKey = oReg.GetDWORDValue(HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue)

If CheckKey = "0" And strValue = 1 then
    'Set the Key to = dwValue
    oReg.SetDWORDValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,dwValue
    strValue = Null
Elseif strValue = 0 then
    Msgbox "Remote Desktop Connection is not enables.  Please try again."
    wscript.Quit
Else
    Msgbox "Registry key does not exist"
    Wscript.quit
End If

'Check to see if key was set correctly.
oReg.GetDWORDValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue

If strValue = 0 then
    ret = Msgbox("Remote Desktop Connection has been enabled, Do you want to reboot the PC?" & vbCr _
    & "If yes, this will reboot the PC immediately, all unsaved data will be lost.",vbYesNo)
    If ret = vbYes then
        DoReboot = True
    Else
        Msgbox "For the changes to take affect, you must reboot the PC."
    End If
ElseIf strValue = 1 Then
    Msgbox "Remote Desktop Connection is disabled"
Else
    Msgbox "Registry key does not exist"
    Wscript.quit
End If

'Reboot
If doReboot = True then
    Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate,(Shutdown)}!\\" & strComputer & "\root\cimv2")
    Set colOperatingSystems = objWMIService.ExecQuery("Select * from Win32_OperatingSystem")
    For Each objOperatingSystem in colOperatingSystems
        objOperatingSystem.Reboot()
    Next
End If

Msgbox "Done"

_____________________________

Mike

For useful Scripting links see the Read Me First stickey!

Always remember Search is your friend.

(in reply to mbouchard)
 
 
Post #: 5
 
 RE: change remote desktop settings - 8/28/2005 10:52:47 PM   
  the_apostle21


Posts: 54
Score: 0
Joined: 7/29/2005
Status: offline
thanks for you help, mbouchard....greatly appreciated.

i found some examples in the script center, but i cant understand the one i found for adding a user to a group.  here is what i found:

strComputer = "."
Set objGroup = GetObject("WinNT://" & strComputer & "/Administrators,group")
Set objUser = GetObject("WinNT://" & strComputer & "/jsmith,user")
objGroup.Add(objUser.ADsPath)


can you please shed some light on how this script is supposed to work, as i have had none!!!

thanks heaps.

(in reply to mbouchard)
 
 
Post #: 6
 
 RE: change remote desktop settings - 8/28/2005 11:00:14 PM   
  mbouchard


Posts: 1916
Score: 16
Joined: 5/15/2003
From: USA
Status: offline
strComputer = "." 'This is the name of the computer that the script will be run on.
Set objGroup = GetObject("WinNT://" & strComputer & "/Administrators,group") 'everthing between the // and , deals with the group, so, you would just change the Administrators to which ever group you want to add too.
Set objUser = GetObject("WinNT://" & strComputer & "/jsmith,user") 'Everthing between the // and , deals with the user that you are adding, so, if is was a domain user, you would have this:
Set objUser = GetObject("WinNT://SOMEDOMAIN/jsmith,user")
objGroup.Add(objUser.ADsPath)

_____________________________

Mike

For useful Scripting links see the Read Me First stickey!

Always remember Search is your friend.

(in reply to the_apostle21)
 
 
Post #: 7
 
 RE: change remote desktop settings - 8/29/2005 10:23:16 PM   
  the_apostle21


Posts: 54
Score: 0
Joined: 7/29/2005
Status: offline
so will that script work if i want to add a local user to the remote desktop users group? or is it only for a domain group?

This is what i tried, but it wouldnt work...

thanks again.

(in reply to mbouchard)
 
 
Post #: 8
 
 RE: change remote desktop settings - 8/29/2005 10:37:51 PM   
  mbouchard


Posts: 1916
Score: 16
Joined: 5/15/2003
From: USA
Status: offline
Yes, it would work, post what you have tried.

_____________________________

Mike

For useful Scripting links see the Read Me First stickey!

Always remember Search is your friend.

(in reply to the_apostle21)
 
 
Post #: 9
 
 RE: change remote desktop settings - 9/1/2005 12:07:43 AM   
  the_apostle21


Posts: 54
Score: 0
Joined: 7/29/2005
Status: offline
This is what i tried...

strComputer = "."
Set objGroup = GetObject("WinNT://" & strComputer & "/Remote Desktop Users,group")
Set objUser = GetObject("WinNT://" & strComputer & "/jsmith,user")
objGroup.Add(objUser.ADsPath)

and i get the following error...

Line: 4
Char: 1
Error: A member could not be added to or removed from the local group because the member does not exist.
Code: 8007056B

I am logged in with admin privileges, running win xp sp2, and the member does exist...but i cannot work it out.

any help would be great.

cheers

(in reply to mbouchard)
 
 
Post #: 10
 
 RE: change remote desktop settings - 9/1/2005 1:28:58 AM   
  Country73


Posts: 733
Score: 10
Joined: 8/25/2004
From: USA
Status: offline
Here's a snippet of some code I just had to throw together last week. Didn't have any problems running this.
On this one I had to add 4 individuals to the same group.
**I'm also using "CUSRMGR.EXE" to make the changes (http://support.microsoft.com/default.aspx?scid=kb;en-us;q272530)

Set oShell = CreateObject("Wscript.Shell")
netbios ="." 'Change to run on remote machine.
MyArray = array("DOMAIN\johnsmith0","DOMAIN\johnsmith1","DOMAIN\johnsmith2","DOMAIN\johnsmith3") 'Change to reflect your Domain/Users

'Step through the Array to add each user into Remote Desktop Users group
'Users must exist in "DOMAIN"
For I = 0 to Ubound(MyArray)
   strUsername = MyArray(I)
oShell.Run "cusrmgr.exe -u " & strUsername & " -m " & netbios & " -alg ""Remote Desktop Users""",0,True
Next
wscript.echo "Completed"

(in reply to the_apostle21)
 
 
Post #: 11
 
 RE: change remote desktop settings - 9/1/2005 1:36:21 AM   
  mbouchard


Posts: 1916
Score: 16
Joined: 5/15/2003
From: USA
Status: offline
Is jsmith a username of a local user?

quote:

ORIGINAL: the_apostle21

This is what i tried...

strComputer = "."
Set objGroup = GetObject("WinNT://" & strComputer & "/Remote Desktop Users,group")
Set objUser = GetObject("WinNT://" & strComputer & "/jsmith,user")
objGroup.Add(objUser.ADsPath)

and i get the following error...

Line: 4
Char: 1
Error: A member could not be added to or removed from the local group because the member does not exist.
Code: 8007056B

I am logged in with admin privileges, running win xp sp2, and the member does exist...but i cannot work it out.

any help would be great.

cheers


_____________________________

Mike

For useful Scripting links see the Read Me First stickey!

Always remember Search is your friend.

(in reply to the_apostle21)
 
 
Post #: 12
 
 RE: change remote desktop settings - 9/2/2005 1:42:13 PM   
  the_apostle21


Posts: 54
Score: 0
Joined: 7/29/2005
Status: offline
Hi Country73,
i dont really want to use apps that are not included with a base win xp install.

Hi mbouchard,
yes, jsmith is a local user.  i created it for this purpose.

so does that script work for you guys??

(in reply to mbouchard)
 
 
Post #: 13
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> change remote desktop settings Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts