|
|
本帖最后由 winlong102 于 2026-7-7 10:46 编辑
话不多说,上代码:
- @echo off
- chcp 936
- :: 检查是否带有隐藏参数 "h"
- if "%1"=="h" goto begin
- :: 如果没有参数,则通过 mshta 调用 vbscript 重新以隐藏模式启动自身
- start mshta vbscript:CreateObject("WScript.Shell").Run("""%~f0"" h",0)(window.close)&&exit
- :begin
- setlocal enabledelayedexpansion
- for /f "tokens=2 delims=:" %%a in ('ipconfig ^| findstr /i "ipv4"') do (
- set "ip=%%a"
- goto :break
- )
- :break
- if defined ip set "ip=%ip: =%"
- set "psPath=%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe"
- start /b "" powershell -NoProfile -Command "$ip='%ip%';if([string]::IsNullOrWhiteSpace($ip)){$ip='未获取'};Add-Type -AssemblyName System.Windows.Forms;Add-Type -AssemblyName System.Drawing;Add-Type -MemberDefinition '[DllImport(\"user32.dll\")] public static extern IntPtr SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam); [DllImport(\"user32.dll\")] public static extern bool ReleaseCapture();' -Name User32 -Namespace WinAPI -PassThru | Out-Null;$form=New-Object System.Windows.Forms.Form;$form.Text='IP';$form.FormBorderStyle='None';$form.ControlBox=$false;$form.ShowInTaskbar=$false;$form.TopMost=$true;$form.BackColor='White';$form.TransparencyKey='White';$form.StartPosition='Manual';$label=New-Object System.Windows.Forms.Label;$label.Text='IP地址: '+$ip;$label.Font=New-Object System.Drawing.Font('SimSun',12,[System.Drawing.FontStyle]::Regular);$label.AutoSize=$true;$label.BackColor='White';$label.ForeColor='Black';$label.Cursor=[System.Windows.Forms.Cursors]::SizeAll;$form.Controls.Add($label);$form.ClientSize=$label.Size;$x=[System.Windows.Forms.Screen]::PrimaryScreen.Bounds.Width-$form.Width-10;$y=[System.Windows.Forms.Screen]::PrimaryScreen.Bounds.Height-$form.Height-80;$form.Location=New-Object System.Drawing.Point($x,$y);$label.Add_MouseDown({param($s,$e)if($e.Button -eq 'Left'){[WinAPI.User32]::ReleaseCapture();[WinAPI.User32]::SendMessage($form.Handle,0xA1,2,0);}});$form.Add_Shown({$form.Activate()});$form.Add_FormClosing({$form.Dispose()});[System.Windows.Forms.Application]::Run($form)"
复制代码
总在最前且可以拖动到任何位置。20年的老粉没权限上传图片,就不传效果了,自己运行看吧。
|
|