当前位置: 首页 > news >正文

用BAT和VBS搜集AD中的客户PC资料

看完了要回复啊,提高一下我的BLOG人气~

[版权所有,同属两人,谢谢浏览]

  最近想写一个脚本,用来处理工作中的事务,具体的需求还没怎么想好,但是就想实现这样一个功能,不用亲自的去客户端机器搜集信息,把脚本放在AD服务器上,客户登陆的时候就可以运行,也可以增加一个AD策略,将所有的信息搜集,发到指定的邮箱里!

下面是我搜集客户信息的一些DOS命令
================================================
systeminfo >c:\star.rtf
ipconfig |find "IP Address">>c:\star.rtf
route print >>c:\star.rtf
netstat -an |find "LISTENING" >>c:\star.rtf
=================================================
%1"== 这个参数是在 运行BAT的时候需要你输入的,有空格~
将下面保存为sendmail.bat 运行 sendmail.bat yourmail@yourmailserver.com

@echo off
REM MAIL Setting
if "%1"=="" goto :show
::这里你可以任意的加DOS命令[可以参考我上面的命令]
::cd \ && c: && cd pro* && cd winrar
::rar a c:\star.rar c:\star.rtf
set Mexecfile="S_MAIL.vbs"
set mailfrom=/fr "yourmail@yourmailserver.com.cn"
set mailto=/to "%1"
set mailsub=/sub "客户PC系统在%date% %time%的状态"
:: Mail mess
set mailmes=/mes "[这个是一个自动发邮件的脚本,检测客户PC的运行状态]"
:: User Name
set user=/muser "yourmailusername"
:: Password
set password=/mpasswd "yourmailpassword"
set add=/add "c:\star.rtf"
REM smtpServer
::推荐用126邮箱,或者smtp为端口为25的。
rem set smtpServer=/s "smtp.gmail.com"
set smtpServer=/s "mail.yourmailserver.com"

set other=/sh /mail /au %add%
%Mexecfile% %smtpServer% %mailto% %mailFrom% %user% %password% %mailsub% %mailmes% %other%
:Show
echo plz type u want mailto mail address
goto :End
:End
================================================

下面是一个热心的朋友给我写的vbs,主要的功能都在这里~
——————————————————————————————
——————————————————————————————
再次感谢台湾的程序员的帮助,谢谢,不好提名~ 心知

存为 S_MAIL.vbs

' *************************************************
' S_mail.vbs 2005'12'27
' S_mail.vbs /s 192.168.1.10 /to test@test.com.tw /cc test@test.com.tw /fr log@MAIL /sub "testaa" /mes aaa /sh /MAIL
' edit 2006/01/04
' edit 2006/01/07
' edit 2006/01/12
' edit 2006/12/07

' *************************************************
Option Explicit

' *********************** DIM *********************
dim mailfrom,mailto,mailcc,mailsub,mailmess,MXserver,mailsmtpport,mailuser,mailpasswd
dim objEmail,msgerr
Dim stry,strm,strd,strtxt
dim fush,fuc
Dim strFlag,intState,i
Dim objFileSystem
dim FSO,objfile,ReadAllTextFile
dim add,addfile,userpd
dim strsmptaut,smptaut,htmlchk
dim strsmtpssl,smtpssl
' ***********************EDIT ***********************


' *********************** PROGRAM ***********************
call argm
CALL funchk

' ***********************SUB PROGRAM ***********************
sub argm
if Wscript.arguments.Count > 1 then
add = 0
userpd = 0
mailsmtpport = 25
for i = 0 to Wscript.arguments.Count -1
select case LCase(Wscript.arguments.Item(i))
case "/s"
MXserver = LCase(Wscript.arguments.Item(i+1))
case "/to"
mailto = LCase(Wscript.arguments.Item(i+1))
case "/cc"
mailcc = LCase(Wscript.arguments.Item(i+1))
case "/fr"
mailfrom = LCase(Wscript.arguments.Item(i+1))
case "/sub"
Mailsub = LCase(Wscript.arguments.Item(i+1))
case "/mes"
mailmess = LCase(Wscript.arguments.Item(i+1))
if mailmess = "file" then
Set FSO = CreateObject("Scripting.FileSystemObject")
Set objfile = FSO.OpenTextFile(Wscript.arguments.Item(i+2),1)
ReadAllTextFile = objfile.ReadAll
objfile.close
end if

case "/add"
add = 1
addfile = LCase(Wscript.arguments.Item(i+1))
case "/html"
htmlchk=1
case "/muser"
userpd = userpd + 1
mailuser = LCase(Wscript.arguments.Item(i+1))

case "/mpasswd"
userpd = userpd + 1
mailpasswd = Wscript.arguments.Item(i+1)

case "/au"
strsmptaut = "Yes"
smptaut = 1
case "/ssl"
strsmtpssl = "Yes"
SmtpSSL = 1

case "/sport"
mailsmtpport =int(Wscript.arguments.Item(i+1))

case "/sh"
fush = 1

case "/mail"
fuc = 1
end select
next
else
call usage
end if
end sub

sub funchk
if mailto = "" or mailfrom = "" or Mailsub = "" or mailmess = "" or MXserver = "" then
if mailfrom = "" then mailfrom = "/fr Mail From"
if mailto = "" then mailto = "/to Mail To"
if Mailsub = "" then Mailsub = "/sub Subject"
if mailmess = "" then mailmess = "/mes Message"
if MXserver = "" then MXserver = "/s Smtp Server"

call showlok
wscript.echo "You can type mal.vbs /? or mal.vbs "
wscript.quit
end if
if fush = 1 then call showlok
if fuc = 1 then call mlt
end sub

sub usage
wscript.echo ""
wscript.echo ""
wscript.echo "Executes a command."
wscript.echo ""
wscript.echo " SYNTAX: "
wscript.echo ""
wscript.echo " [/s ] "
wscript.echo " [/to ] [/cc] [/fr ]"
wscript.echo " [/sub ] [/mes | file FileName ] "
wscript.echo " [/sh ] [/mail ]"
wscript.echo " [/add ]"
wscript.echo " [/au ]"
wscript.echo " [/SSL ]"
wscript.echo " [/html ]"
wscript.quit
end sub

sub showlok
wscript.echo ""
wscript.echo "MAIL FROM : " & mailfrom
wscript.echo "MAIL TO : " & mailto
wscript.echo "MAIL SUB : " & Mailsub
wscript.echo "MAIL MESS : " & mailmess
wscript.echo "SMTP Server : " & MXserver
if smptaut = 1 then wscript.echo "SMTP Authenticate: " & strsmptaut
if smtpssl = 1 then wscript.echo "SMTP SSL: " & strSmtpSSL
if htmlchk=1 then wscript.echo " HtmlBody Send"
wscript.echo
end sub
'*********

sub mlt
Set objEmail = CreateObject("CDO.Message")
if mailmess = "file" then mailmess = ReadAllTextFile
with objEmail
.From = mailfrom
.To = mailto
.cc = mailcc
.Subject = mailsub
if htmlchk=1 then
.htmlbody=mailmess
else
.Textbody = mailmess
end if
'Ж郎
if add = 1 then
.AddAttachment addfile
end if

if userpd = 2 then
.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = mailuser
.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = mailpasswd
end if

if smptaut = 1 then
.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
end if
if smtpssl = 1 then
.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = true
end if

.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = MXserver
.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = mailsmtpport
.Configuration.Fields.Update
.Send
end with
end sub
'**********
' end

综上所述,你就可以发信了~ 有不明白的可以

sendMail to Me star33375249(at)gmail(dot)com

相关文章:

  • Lua string.format() 使用整理
  • 一个成功创业者的心得
  • Lua实战之以非科学记数法输出小数
  • SVN服务器的搭建与使用
  • 犹太人常说的理财故事
  • SVN设置强制注释才能提交
  • 35岁前成功的12条黄金法则
  • SVN比较两个文件差异
  • 李嘉诚传给年青人的人生忠告
  • 2021-1024程序员节
  • 成就富翁:赚钱八大定律
  • 安卓系统管理软件_【安卓软件】玩机必备综合型系统管理工具
  • 职业营销人的成长揭秘
  • 为什么Android项目mainactivity中有一个变量R_【Android 原创】日常破解从XCTF的app3题目简单了解安卓备份文件以及sqliteCipher加密数据库...
  • 备份文件的BAT脚本
  • #Java异常处理
  • angular组件开发
  • CSS 专业技巧
  • Java 9 被无情抛弃,Java 8 直接升级到 Java 10!!
  • JDK 6和JDK 7中的substring()方法
  • js 实现textarea输入字数提示
  • Koa2 之文件上传下载
  • Linux中的硬链接与软链接
  • React Transition Group -- Transition 组件
  • windows下如何用phpstorm同步测试服务器
  • windows下使用nginx调试简介
  • 配置 PM2 实现代码自动发布
  • 推荐一个React的管理后台框架
  • 追踪解析 FutureTask 源码
  • ${factoryList }后面有空格不影响
  • (2)关于RabbitMq 的 Topic Exchange 主题交换机
  • (C++)栈的链式存储结构(出栈、入栈、判空、遍历、销毁)(数据结构与算法)
  • (PHP)设置修改 Apache 文件根目录 (Document Root)(转帖)
  • (Redis使用系列) Springboot 使用redis实现接口幂等性拦截 十一
  • (二十三)Flask之高频面试点
  • (强烈推荐)移动端音视频从零到上手(上)
  • (深入.Net平台的软件系统分层开发).第一章.上机练习.20170424
  • (推荐)叮当——中文语音对话机器人
  • (万字长文)Spring的核心知识尽揽其中
  • (一)80c52学习之旅-起始篇
  • (一)Mocha源码阅读: 项目结构及命令行启动
  • (原創) 人會胖會瘦,都是自我要求的結果 (日記)
  • .axf 转化 .bin文件 的方法
  • .bat批处理出现中文乱码的情况
  • .Net IOC框架入门之一 Unity
  • .Net Memory Profiler的使用举例
  • .NET 使用 ILRepack 合并多个程序集(替代 ILMerge),避免引入额外的依赖
  • .NET 事件模型教程(二)
  • .NET(C#、VB)APP开发——Smobiler平台控件介绍:Bluetooth组件
  • .net之微信企业号开发(一) 所使用的环境与工具以及准备工作
  • .net知识和学习方法系列(二十一)CLR-枚举
  • .net中的Queue和Stack
  • .Net转Java自学之路—基础巩固篇十三(集合)
  • @autowired注解作用_Spring Boot进阶教程——注解大全(建议收藏!)
  • @private @protected @public