zoukankan      html  css  js  c++  java
  • 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

    做一个决定,并不难,难的是付诸行动,并且坚持到底。
  • 相关阅读:
    6:python2、python3 的区别及小数据池
    web前端----html表单操作
    web前端----html基础
    mysql数据库----索引原理与慢查询优化
    MySQL数据库----流程控制
    MySQL数据库----IDE工具介绍及数据备份
    MySQL数据库----数据锁
    MySQL数据库----事务处理
    MySQL数据库----事务
    MySQL数据库----函数
  • 原文地址:https://www.cnblogs.com/wukc/p/13236153.html
Copyright © 2011-2022 走看看