用bat和vbs等简易程序获取本机IP、系统版本、已开放端口 等信息并发送至指定邮.箱?
发布网友
发布时间:2022-05-07 20:42
我来回答
共2个回答
热心网友
时间:2023-11-10 23:27
VBS获取系统版本
set col = getobject("winmgmts://./root/cimv2").ExecQuery("Select * from Win32_OperatingSystem")
for each psp in col
msgbox psp.caption & vbcrlf & psp.version
next
批处理获取系统端口信息,网上找的,不知道是不是你要的
@echo off
color a
Title XP端口-进程查询
setlocal enabledelayedexpansion
echo ╔- -╗
echo 本机开放的端口及使用该端口的进程
echo ╚- -╝
echo ------------------------------------
echo 端口号 进程名称
ECHO TCP协议:
::利用netstat命令找出使用TCP协议通信的端口,并将结果分割;
::将第二个参数(IP加端口)传给%%i,第五个参数(PID号)传给%%j;
for /F "usebackq skip=4 tokens=2,5" %%i in (`"netstat -ano -p TCP"`) do (
call :Assoc %%i TCP %%j
echo !TCP_Port! !TCP_Proc_Name!
)
ECHO UDP协议:
for /F "usebackq skip=4 tokens=2,4" %%i in (`"netstat -ano -p UDP"`) do (
call :Assoc %%i UDP %%j
echo !UDP_Port! !UDP_Proc_Name!
)
echo 按任意键退出
pause>nul
:Assoc
::对%1(第一个参数)进行分割,将第二个参数传给%%e。在本程序中,%1即为上面的%%i(形式为:IP:端口号)
for /F "tokens=2 delims=:" %%e in ("%1") do (
set %2_Port=%%e
)
:: 查询PID等于%3(第三个参数)的进程,并将结果传给变量?_Proc_Name,?代表UDP或者TCP;
for /F "skip=2 usebackq delims=, tokens=1" %%a in (`"Tasklist /FI "PID eq %3" /FO CSV"`) do (
::%%~a表示去掉%%a外面的引号,因为上述命令的结果是用括号括起来的。
set %2_Proc_Name=%%~a
)
VBS发送邮件,现在任然是没有问题的,XP,WIN7都没问题
msgbox Send_mail("发件人","密码","收件人","抄送","标题","正文","附件")
Function Send_mail(You_Account, You_Password, Send_Email, Send_Email2, Send_Topic, Send_Body, Send_Attachment)
On Error Resume Next
Dim You_ID, MS_Space, Email
You_ID = Split(You_Account, "@", -1, vbTextCompare)
MS_Space = "
http://schemas.microsoft.com/cdo/configuration/
"
Set Email = CreateObject("CDO.Message")
Email.From = You_Account
Email.To = Send_Email
If Send_Email2 <> "" Then
Email.CC = Send_Email2
End If
Email.Subject = Send_Topic
Email.Textbody = Send_Body
If Send_Attachment <> "" Then
Email.AddAttachment Send_Attachment
End If
With Email.Configuration.Fields
.Item(MS_Space & "sensing") = 2
.Item(MS_Space & "smtpserver") = "smtp." & You_ID(1)
.Item(MS_Space & "smtpserverport") = 25
.Item(MS_Space & "smtpauthenticate") = 1
.Item(MS_Space & "sensername") = You_ID(0)
.Item(MS_Space & "sendpassword") = You_Password
.Update
End With
Email.Send
Set Email=Nothing
Send_Mail=True
If Err Then
Err.Clear
Send_Mail=False
End If
End Function
你自己组合一下吧
热心网友
时间:2023-11-10 23:27
VBS获取系统版本
set col = getobject("winmgmts://./root/cimv2").ExecQuery("Select * from Win32_OperatingSystem")
for each psp in col
msgbox psp.caption & vbcrlf & psp.version
next
批处理获取系统端口信息,网上找的,不知道是不是你要的
@echo off
color a
Title XP端口-进程查询
setlocal enabledelayedexpansion
echo ╔- -╗
echo 本机开放的端口及使用该端口的进程
echo ╚- -╝
echo ------------------------------------
echo 端口号 进程名称
ECHO TCP协议:
::利用netstat命令找出使用TCP协议通信的端口,并将结果分割;
::将第二个参数(IP加端口)传给%%i,第五个参数(PID号)传给%%j;
for /F "usebackq skip=4 tokens=2,5" %%i in (`"netstat -ano -p TCP"`) do (
call :Assoc %%i TCP %%j
echo !TCP_Port! !TCP_Proc_Name!
)
ECHO UDP协议:
for /F "usebackq skip=4 tokens=2,4" %%i in (`"netstat -ano -p UDP"`) do (
call :Assoc %%i UDP %%j
echo !UDP_Port! !UDP_Proc_Name!
)
echo 按任意键退出
pause>nul
:Assoc
::对%1(第一个参数)进行分割,将第二个参数传给%%e。在本程序中,%1即为上面的%%i(形式为:IP:端口号)
for /F "tokens=2 delims=:" %%e in ("%1") do (
set %2_Port=%%e
)
:: 查询PID等于%3(第三个参数)的进程,并将结果传给变量?_Proc_Name,?代表UDP或者TCP;
for /F "skip=2 usebackq delims=, tokens=1" %%a in (`"Tasklist /FI "PID eq %3" /FO CSV"`) do (
::%%~a表示去掉%%a外面的引号,因为上述命令的结果是用括号括起来的。
set %2_Proc_Name=%%~a
)
VBS发送邮件,现在任然是没有问题的,XP,WIN7都没问题
msgbox Send_mail("发件人","密码","收件人","抄送","标题","正文","附件")
Function Send_mail(You_Account, You_Password, Send_Email, Send_Email2, Send_Topic, Send_Body, Send_Attachment)
On Error Resume Next
Dim You_ID, MS_Space, Email
You_ID = Split(You_Account, "@", -1, vbTextCompare)
MS_Space = "
http://schemas.microsoft.com/cdo/configuration/
"
Set Email = CreateObject("CDO.Message")
Email.From = You_Account
Email.To = Send_Email
If Send_Email2 <> "" Then
Email.CC = Send_Email2
End If
Email.Subject = Send_Topic
Email.Textbody = Send_Body
If Send_Attachment <> "" Then
Email.AddAttachment Send_Attachment
End If
With Email.Configuration.Fields
.Item(MS_Space & "sensing") = 2
.Item(MS_Space & "smtpserver") = "smtp." & You_ID(1)
.Item(MS_Space & "smtpserverport") = 25
.Item(MS_Space & "smtpauthenticate") = 1
.Item(MS_Space & "sensername") = You_ID(0)
.Item(MS_Space & "sendpassword") = You_Password
.Update
End With
Email.Send
Set Email=Nothing
Send_Mail=True
If Err Then
Err.Clear
Send_Mail=False
End If
End Function
你自己组合一下吧
热心网友
时间:2023-11-10 23:28
BAT不可以发邮箱,VBS以前可以,现在不可以了。追问没有其他方法了么?
追答易语言可以,VB C++ 都可以。。。
然后还有就是BAT用第三方,上传到FTP服务器。
反正这单纯两个脚本到不到你想要的效果
热心网友
时间:2023-11-10 23:27
VBS获取系统版本
set col = getobject("winmgmts://./root/cimv2").ExecQuery("Select * from Win32_OperatingSystem")
for each psp in col
msgbox psp.caption & vbcrlf & psp.version
next
批处理获取系统端口信息,网上找的,不知道是不是你要的
@echo off
color a
Title XP端口-进程查询
setlocal enabledelayedexpansion
echo ╔- -╗
echo 本机开放的端口及使用该端口的进程
echo ╚- -╝
echo ------------------------------------
echo 端口号 进程名称
ECHO TCP协议:
::利用netstat命令找出使用TCP协议通信的端口,并将结果分割;
::将第二个参数(IP加端口)传给%%i,第五个参数(PID号)传给%%j;
for /F "usebackq skip=4 tokens=2,5" %%i in (`"netstat -ano -p TCP"`) do (
call :Assoc %%i TCP %%j
echo !TCP_Port! !TCP_Proc_Name!
)
ECHO UDP协议:
for /F "usebackq skip=4 tokens=2,4" %%i in (`"netstat -ano -p UDP"`) do (
call :Assoc %%i UDP %%j
echo !UDP_Port! !UDP_Proc_Name!
)
echo 按任意键退出
pause>nul
:Assoc
::对%1(第一个参数)进行分割,将第二个参数传给%%e。在本程序中,%1即为上面的%%i(形式为:IP:端口号)
for /F "tokens=2 delims=:" %%e in ("%1") do (
set %2_Port=%%e
)
:: 查询PID等于%3(第三个参数)的进程,并将结果传给变量?_Proc_Name,?代表UDP或者TCP;
for /F "skip=2 usebackq delims=, tokens=1" %%a in (`"Tasklist /FI "PID eq %3" /FO CSV"`) do (
::%%~a表示去掉%%a外面的引号,因为上述命令的结果是用括号括起来的。
set %2_Proc_Name=%%~a
)
VBS发送邮件,现在任然是没有问题的,XP,WIN7都没问题
msgbox Send_mail("发件人","密码","收件人","抄送","标题","正文","附件")
Function Send_mail(You_Account, You_Password, Send_Email, Send_Email2, Send_Topic, Send_Body, Send_Attachment)
On Error Resume Next
Dim You_ID, MS_Space, Email
You_ID = Split(You_Account, "@", -1, vbTextCompare)
MS_Space = "
http://schemas.microsoft.com/cdo/configuration/
"
Set Email = CreateObject("CDO.Message")
Email.From = You_Account
Email.To = Send_Email
If Send_Email2 <> "" Then
Email.CC = Send_Email2
End If
Email.Subject = Send_Topic
Email.Textbody = Send_Body
If Send_Attachment <> "" Then
Email.AddAttachment Send_Attachment
End If
With Email.Configuration.Fields
.Item(MS_Space & "sensing") = 2
.Item(MS_Space & "smtpserver") = "smtp." & You_ID(1)
.Item(MS_Space & "smtpserverport") = 25
.Item(MS_Space & "smtpauthenticate") = 1
.Item(MS_Space & "sensername") = You_ID(0)
.Item(MS_Space & "sendpassword") = You_Password
.Update
End With
Email.Send
Set Email=Nothing
Send_Mail=True
If Err Then
Err.Clear
Send_Mail=False
End If
End Function
你自己组合一下吧
热心网友
时间:2023-11-10 23:27
VBS获取系统版本
set col = getobject("winmgmts://./root/cimv2").ExecQuery("Select * from Win32_OperatingSystem")
for each psp in col
msgbox psp.caption & vbcrlf & psp.version
next
批处理获取系统端口信息,网上找的,不知道是不是你要的
@echo off
color a
Title XP端口-进程查询
setlocal enabledelayedexpansion
echo ╔- -╗
echo 本机开放的端口及使用该端口的进程
echo ╚- -╝
echo ------------------------------------
echo 端口号 进程名称
ECHO TCP协议:
::利用netstat命令找出使用TCP协议通信的端口,并将结果分割;
::将第二个参数(IP加端口)传给%%i,第五个参数(PID号)传给%%j;
for /F "usebackq skip=4 tokens=2,5" %%i in (`"netstat -ano -p TCP"`) do (
call :Assoc %%i TCP %%j
echo !TCP_Port! !TCP_Proc_Name!
)
ECHO UDP协议:
for /F "usebackq skip=4 tokens=2,4" %%i in (`"netstat -ano -p UDP"`) do (
call :Assoc %%i UDP %%j
echo !UDP_Port! !UDP_Proc_Name!
)
echo 按任意键退出
pause>nul
:Assoc
::对%1(第一个参数)进行分割,将第二个参数传给%%e。在本程序中,%1即为上面的%%i(形式为:IP:端口号)
for /F "tokens=2 delims=:" %%e in ("%1") do (
set %2_Port=%%e
)
:: 查询PID等于%3(第三个参数)的进程,并将结果传给变量?_Proc_Name,?代表UDP或者TCP;
for /F "skip=2 usebackq delims=, tokens=1" %%a in (`"Tasklist /FI "PID eq %3" /FO CSV"`) do (
::%%~a表示去掉%%a外面的引号,因为上述命令的结果是用括号括起来的。
set %2_Proc_Name=%%~a
)
VBS发送邮件,现在任然是没有问题的,XP,WIN7都没问题
msgbox Send_mail("发件人","密码","收件人","抄送","标题","正文","附件")
Function Send_mail(You_Account, You_Password, Send_Email, Send_Email2, Send_Topic, Send_Body, Send_Attachment)
On Error Resume Next
Dim You_ID, MS_Space, Email
You_ID = Split(You_Account, "@", -1, vbTextCompare)
MS_Space = "
http://schemas.microsoft.com/cdo/configuration/
"
Set Email = CreateObject("CDO.Message")
Email.From = You_Account
Email.To = Send_Email
If Send_Email2 <> "" Then
Email.CC = Send_Email2
End If
Email.Subject = Send_Topic
Email.Textbody = Send_Body
If Send_Attachment <> "" Then
Email.AddAttachment Send_Attachment
End If
With Email.Configuration.Fields
.Item(MS_Space & "sensing") = 2
.Item(MS_Space & "smtpserver") = "smtp." & You_ID(1)
.Item(MS_Space & "smtpserverport") = 25
.Item(MS_Space & "smtpauthenticate") = 1
.Item(MS_Space & "sensername") = You_ID(0)
.Item(MS_Space & "sendpassword") = You_Password
.Update
End With
Email.Send
Set Email=Nothing
Send_Mail=True
If Err Then
Err.Clear
Send_Mail=False
End If
End Function
你自己组合一下吧
热心网友
时间:2023-11-10 23:28
BAT不可以发邮箱,VBS以前可以,现在不可以了。追问没有其他方法了么?
追答易语言可以,VB C++ 都可以。。。
然后还有就是BAT用第三方,上传到FTP服务器。
反正这单纯两个脚本到不到你想要的效果
热心网友
时间:2023-11-10 23:27
VBS获取系统版本
set col = getobject("winmgmts://./root/cimv2").ExecQuery("Select * from Win32_OperatingSystem")
for each psp in col
msgbox psp.caption & vbcrlf & psp.version
next
批处理获取系统端口信息,网上找的,不知道是不是你要的
@echo off
color a
Title XP端口-进程查询
setlocal enabledelayedexpansion
echo ╔- -╗
echo 本机开放的端口及使用该端口的进程
echo ╚- -╝
echo ------------------------------------
echo 端口号 进程名称
ECHO TCP协议:
::利用netstat命令找出使用TCP协议通信的端口,并将结果分割;
::将第二个参数(IP加端口)传给%%i,第五个参数(PID号)传给%%j;
for /F "usebackq skip=4 tokens=2,5" %%i in (`"netstat -ano -p TCP"`) do (
call :Assoc %%i TCP %%j
echo !TCP_Port! !TCP_Proc_Name!
)
ECHO UDP协议:
for /F "usebackq skip=4 tokens=2,4" %%i in (`"netstat -ano -p UDP"`) do (
call :Assoc %%i UDP %%j
echo !UDP_Port! !UDP_Proc_Name!
)
echo 按任意键退出
pause>nul
:Assoc
::对%1(第一个参数)进行分割,将第二个参数传给%%e。在本程序中,%1即为上面的%%i(形式为:IP:端口号)
for /F "tokens=2 delims=:" %%e in ("%1") do (
set %2_Port=%%e
)
:: 查询PID等于%3(第三个参数)的进程,并将结果传给变量?_Proc_Name,?代表UDP或者TCP;
for /F "skip=2 usebackq delims=, tokens=1" %%a in (`"Tasklist /FI "PID eq %3" /FO CSV"`) do (
::%%~a表示去掉%%a外面的引号,因为上述命令的结果是用括号括起来的。
set %2_Proc_Name=%%~a
)
VBS发送邮件,现在任然是没有问题的,XP,WIN7都没问题
msgbox Send_mail("发件人","密码","收件人","抄送","标题","正文","附件")
Function Send_mail(You_Account, You_Password, Send_Email, Send_Email2, Send_Topic, Send_Body, Send_Attachment)
On Error Resume Next
Dim You_ID, MS_Space, Email
You_ID = Split(You_Account, "@", -1, vbTextCompare)
MS_Space = "
http://schemas.microsoft.com/cdo/configuration/
"
Set Email = CreateObject("CDO.Message")
Email.From = You_Account
Email.To = Send_Email
If Send_Email2 <> "" Then
Email.CC = Send_Email2
End If
Email.Subject = Send_Topic
Email.Textbody = Send_Body
If Send_Attachment <> "" Then
Email.AddAttachment Send_Attachment
End If
With Email.Configuration.Fields
.Item(MS_Space & "sensing") = 2
.Item(MS_Space & "smtpserver") = "smtp." & You_ID(1)
.Item(MS_Space & "smtpserverport") = 25
.Item(MS_Space & "smtpauthenticate") = 1
.Item(MS_Space & "sensername") = You_ID(0)
.Item(MS_Space & "sendpassword") = You_Password
.Update
End With
Email.Send
Set Email=Nothing
Send_Mail=True
If Err Then
Err.Clear
Send_Mail=False
End If
End Function
你自己组合一下吧
热心网友
时间:2023-11-10 23:28
BAT不可以发邮箱,VBS以前可以,现在不可以了。追问没有其他方法了么?
追答易语言可以,VB C++ 都可以。。。
然后还有就是BAT用第三方,上传到FTP服务器。
反正这单纯两个脚本到不到你想要的效果
热心网友
时间:2023-11-10 23:28
BAT不可以发邮箱,VBS以前可以,现在不可以了。追问没有其他方法了么?
追答易语言可以,VB C++ 都可以。。。
然后还有就是BAT用第三方,上传到FTP服务器。
反正这单纯两个脚本到不到你想要的效果
热心网友
时间:2023-11-10 23:28
BAT不可以发邮箱,VBS以前可以,现在不可以了。追问没有其他方法了么?
追答易语言可以,VB C++ 都可以。。。
然后还有就是BAT用第三方,上传到FTP服务器。
反正这单纯两个脚本到不到你想要的效果