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防火牆——例外:勾選「遠程桌面