码迷,mamicode.com
首页 > 其他好文 > 详细

cmd-开起远程桌面并显示ip

时间:2020-07-04 21:06:03      阅读:90      评论:0      收藏:0      [点我收藏+]

标签:ntc   ice   cal   service   防火墙   creat   sre   adl   oca   

前提: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_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal 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

标签:ntc   ice   cal   service   防火墙   creat   sre   adl   oca   

原文地址:https://www.cnblogs.com/wukc/p/13236153.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!