cmd-开起远程桌面并显示ip
Posted wukc
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了cmd-开起远程桌面并显示ip相关的知识,希望对你有一定的参考价值。
前提:windows7
‘1关闭防火墙
set objFirewall=CreateObject("HNetCfg.FwPolicy2")
Const NET_FW_PROFILE2_DOMAIN = 1
Const NET_FW_PROFILE2_PRIVATE = 2
Const NET_FW_PROFILE2_PUBLIC = 4
objFirewall.FirewallEnabled(NET_FW_PROFILE2_DOMAIN) = False
objFirewall.FirewallEnabled(NET_FW_PROFILE2_PRIVATE) = False
objFirewall.FirewallEnabled(NET_FW_PROFILE2_PUBLIC) = False
‘2开启服务
set ws=createobject("wscript.shell")
ws.run "cmd /c net start ""Remote Desktop Help Session Manager""",0,ture
ws.run "cmd /c net start ""Remote Desktop Services""",0,ture
‘3设置远程的注册表
Set vbsRegWrite = CreateObject("Wscript.Shell")
Dim path
path = "HKEY_LOCAL_MACHINESYSTEMCurrentControlSetControlTerminal Server"
vbsRegWrite.RegWrite path & "fDenyTSConnections","0","REG_DWORD"
‘4获取ip
Set WshShell = WScript.CreateObject("WScript.Shell")
Set oExec = WshShell.Exec("ipconfig.exe")
Set oStdOut = oExec.StdOut
ip = ""
Do Until oStdOut.AtEndOfStream
strLine = oStdOut.ReadLine
If InStr(strLine, "IPv4 地址") > 0 Then
ip = Mid(strLine, InStr(strLine, ":") + 2)
Exit Do
End If
Loop
If ip = "" Then
MsgBox "获取本地连接IP地址失败!", vbExclamation, "错误"
WScript.Quit
Else
MsgBox ip, vbExclamation, "本地连接IP地址!"
End If
WScript.Quit
以上是关于cmd-开起远程桌面并显示ip的主要内容,如果未能解决你的问题,请参考以下文章