1. mstsc 保存用户名和密码,实现自动登录远程桌面
首先手动连接远程桌面,登陆时记得保存连接,得到.rdp文件。
在.rdp文件中结尾处添加用户名以及密码信息:
username:s: yourname
password 51:b: yourpasswd
批处理命令:
start "RemoteConsole %destIP%" mstsc %destIP%.rdp /v:%destIP%
密码生成工具
https://www.remkoweijnen.nl/blog/2007/10/18/how-rdp-passwords-are-encrypted/
/////////////////////////////////////////////
以下为 Python (Version 2.7)脚本一键登陆远程桌面:
#coding:utf-8
import win32crypt
import binascii
import os
import Tkinter
import tkMessageBox
import tkFileDialog
def genRdpPasswd(passwd):
#passwd must be unicode!!!!!!!!!!!!!!!!!!!!!!!!!!
pwdHash = win32crypt.CryptProtectData(passwd, u'psw', None, None, None, 0)
pwdHash_ok = binascii.hexlify(pwdHash)
#print len(pwdHash_ok)
#print pwdHash_ok
return pwdHash_ok
def logIn():
rdpStr = u'''screen mode id:i:2
use multimon:i:0
desktopwidth:i:1920
desktopheight:i:1080
session bpp:i:32
winposstr:s:0,1,917,8,1744,1003
compression:i:1
keyboardhook:i:2
audiocapturemode:i:0
videoplaybackmode:i:1
connection type:i:7
networkautodetect:i:1
bandwidthautodetect:i:1
displayconnectionbar:i:1
enableworkspacereconnect:i:0
disable wallpaper:i:0
allow font smoothing:i:0
allow desktop composition:i:0
disable full window drag:i:1
disable menu anims:i:1
disable themes:i:0
disable cursor setting:i:0
bitmapcachepersistenable:i:1
audiomode:i:0
redirectprinters:i:1
redirectcomports:i:0
redirectsmartcards:i:1
redirectclipboard:i:1
redirectposdevices:i:0
autoreconnection enabled:i:1
authentication level:i:2
prompt for credentials:i:0
negotiate security layer:i:1
remoteapplicationmode:i:0
alternate shell:s:
shell working directory:s:
gatewayhostname:s:
gatewayusagemethod:i:4
gatewaycredentialssource:i:4
gatewayprofileusagemethod:i:0
promptcredentialonce:i:0
gatewaybrokeringtype:i:0
use redirection server name:i:0
rdgiskdcproxy:i:0
kdcproxyname:s:
drivestoredirect:s:
'''
ip = ipVar.get().decode('utf-8')
username = usernameVar.get().decode('utf-8')
passwd = passwdVar.get().decode('utf-8')
passwd_encrypt = genRdpPasswd(passwd)
print len(ip), ip
print len(username), username
print len(passwd), passwd
print len(passwd_encrypt), passwd_encrypt
rdpStr = rdpStr + "full address:s:%s\r\nusername:s:%s\r\npassword 51:b:%s\r\n"%(ip, username, passwd_encrypt)
with open("AutoRdp.rdp","w") as f:
f.write(rdpStr)
#os.system('start "RemoteConsole %s %s" mstsc AutoRdp.rdp /v:%s'%(ip, username, ip))
os.system('start "RemoteConsole %s %s" mstsc AutoRdp.rdp'%(ip, username))
if "__main__" == __name__:
root = Tkinter.Tk()
ipVar = Tkinter.StringVar()
usernameVar = Tkinter.StringVar()
passwdVar = Tkinter.StringVar()
ipVar.set(u'your default ip')
usernameVar.set(u'your default username')
passwdVar.set(u'your default passwd')
root.title('AutoRdp')
#root.withdraw()
Tkinter.Label(root, text = 'IpAddr:').grid(row = 0, column = 0)
Tkinter.Entry(root, textvariable = ipVar).grid(row = 0, column = 1)
Tkinter.Label(root, text = 'UserName:').grid(row = 1, column = 0)
Tkinter.Entry(root, textvariable = usernameVar).grid(row = 1, column = 1)
Tkinter.Label(root, text = 'PassWord:').grid(row = 2, column = 0)
Tkinter.Entry(root, textvariable = passwdVar).grid(row = 2, column = 1)
Tkinter.Button(root, text = '远程登陆', command = logIn).grid(row = 3, column = 2)
root.mainloop()
2. 如何使用mstsc进行远程登录
首先点击【开始】->【运行】,输入mstsc。如下图:
输入连接服务器的IP地址,然后点击链接,如下图所示:
链接成功之后就输入用户名和密码,如下图:
这样就链接成功了。就阔以进行远程控制了。
有些情况下可能会出现问题,小编配置的时候就出现链接不成功的情况。
可能问题及解决方法:
1、3389端口没有开通[开始]菜单——设置——控制面板——系统——远程属性——勾起:允许用户远程连接到此计算机。
2、服务没有启用[开始]菜单——设置——控制面板——管理工具——服务——找到:Terminal Services服务:更改成“启动”状态。
3、防火墙如果端口和服务都开通了,还是不能连接,那么就有可能是被防火墙禁止了;关闭防火墙 或者 添加3389端口并允
下面是WindowsXP自带的防火墙: [开始]菜单——设置——控制面板——Windows防火墙——例外:勾选“远程桌面