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_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