欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

可以得到当前系统信息的脚本sysinfo.vbs

程序员文章站 2022-07-04 22:31:23
复制代码 代码如下:if (lcase(right(wscript.fullname,11))="wscript.exe") then  &n...
复制代码 代码如下:

if (lcase(right(wscript.fullname,11))="wscript.exe") then
   set objshell=wscript.createobject("wscript.shell")
   objshell.run("cmd.exe /k cscript //nologo "&chr(34)&wscript.scriptfullname&chr(34))
   wscript.quit
end if
with wscript.arguments
if .count>0 then
   ipaddress="."
   outfile=""
   username=""
   password=""
   viewtype=0
   program=0
   for arg=0 to .count-1
      select case left(lcase(.item(arg)),2)
      case "/h","/?","\h","\?"
         usage()
     wscript.quit
      case "/r","\r"
     if arg+3<=.count-1 then
     ipaddress=.item(arg+1)
     username=.item(arg+2)
     password=.item(arg+3)
     else
     wscript.echo "arguments error!"&vbcrlf
     usage()
     wscript.quit
     end if
      case "/v","\v"
     viewtype=1
      case "/o","\o"
     outfile=.item(arg+1)
      case "/a","\a"
     program=1
      end select
   next
end if
end with

on error resume next
if outfile<>"" then
   set fs=createobject("scripting.filesystemobject")
   showerr()
   set of=fs.opentextfile(outfile,8,true)
   showerr()
end if
wscript.echo "getting infomation...."&vbcrlf
set objlocator=createobject("wbemscripting.swbemlocator")
showerr()
set objswb=objlocator.connectserver(ipaddress,"root/cimv2",username,password)
showerr()
on error goto 0

set obj1=objget("win32_computersystem")
set obj2=objget("win32_operatingsystem")
set col3=objswb.instancesof("win32_processor")
set obj4=objget("win32_logicalmemoryconfiguration")
set obj5=objget("win32_bios")
set obj6=objget("win32_displayconfiguration")
set col7=objswb.instancesof("win32_diskdrive")
set col8=objswb.instancesof("win32_logicaldisk")
set col9=objswb.instancesof("win32_networkadapterconfiguration")
set col10=objswb.instancesof("win32_quickfixengineering")
if program=1 then
   set objswb1=objlocator.connectserver(ipaddress,"root/default",username,password)
   set obj11=objswb1.get("stdregprov")
end if

wnl "os info :"
wnl "  computer name : "&obj1.name
wnl "  user name : "&obj1.username
wnl "  domain : "&obj1.domain
domainrole=""
select case obj1.domainrole
case 0
   domainrole="workstation"
case 1
   domainrole="member workstation"
case 2
   domainrole="server"
case 3
   domainrole="member server"
case 4
   domainrole="backup domain controller"
case 5
   domainrole="main domain controller"
end select
with obj2
wnl "  domain role : "&domainrole
wnl "  caption : "&.caption
wnl "  organization : "&.organization
wnl "  registered user : "&.registereduser
wnl "  install date : "&timeformat(.installdate)
wnl "  last bootup time : "&timeformat(.lastbootuptime)
wnl "  windows directory : "&.windowsdirectory
if viewtype=1 then
wnl "  system directory : "&.systemdirectory
wnl "  boot device : "&.bootdevice
wnl "  country code : "&.countrycode
wnl "  csname : "&.csname
wnl "  description : "&.description
wnl "  manufacturer : "&.manufacturer
wnl "  serial number : "&.serialnumber
wnl "  version : "&.version
wnl "  system type : "&obj1.systemtype
wnl "  system startup delay : "&obj1.systemstartupdelay&"s"
wnl "  system startup options : "&obj1.systemstartupoptions(0)
for i=1 to ubound(obj1.systemstartupoptions)
   wnl space(28)&obj1.systemstartupoptions(i)
next
end if
end with

wnl vbcrlf&"processor info :"
wnl "  number of processors : "&obj1.numberofprocessors
for each obj3 in col3
with obj3
wnl "  device id : "&.deviceid
wnl "  name : "&.name
wnl "  current clock speed : "&.currentclockspeed&"mhz"
wnl "  description : "&.description
if viewtype=1 then
wnl "  ext clock : "&.extclock&"mhz"
wnl "  l2 cache size : "&.l2cachesize&"kb"
wnl "  l2 cache speed : "&.l2cachespeed&"mhz"
wnl "  processor id : "&.processorid
wnl "  manufacturer : "&.manufacturer
wnl "  socket designation : "&.socketdesignation
wnl "  address width : "&.addresswidth&"bit"
wnl "  data width : "&.datawidth&"bit"
end if
end with
next

with obj4
wnl vbcrlf&"memory info :"
wnl "  total physical memory : "&cint(.totalphysicalmemory/1024)&"mb"
wnl "  free physical memory : "&cint(obj2.freephysicalmemory/1024)&"mb"
if viewtype=1 then
wnl "  total pagefile space : "&cint(.totalpagefilespace/1024)&"mb"
wnl "  total virtual memory : "&cint(.totalvirtualmemory/1024)&"mb"
wnl "  available virtual memory : "&cint(.availablevirtualmemory/1024)&"mb"
end if
end with

if viewtype=1 then
wnl vbcrlf&"bios info :"
wnl "  description : "&obj5.description
wnl "  current language : "&obj5.currentlanguage
wnl "  version : "&obj5.version
wnl "  manufacturer : "&obj5.manufacturer
end if

with obj6
wnl vbcrlf&"display configuration :"
wnl "  caption : "&.caption
if viewtype=1 then
wnl "  device name : "&.devicename
wnl "  driver version : "&.driverversion
end if
wnl "  display frequency : "&.displayfrequency&"hz"
wnl "  bits per pel : "&.bitsperpel&"bit"
wnl "  pels : "&.pelswidth&" x "&.pelsheight
end with

wnl vbcrlf&"disk info :"
for each obj7 in col7
with obj7
wnl "  deviceid : "&.deviceid
wnl "  caption : "&.caption
wnl "  interface type : "&.interfacetype
if viewtype=1 then
wnl "  scsi bus : "&.scsibus
wnl "  scsi logical unit : "&.scsilogicalunit
wnl "  scsi port : "&.scsiport
wnl "  scsi targetid : "&.scsitargetid
wnl "  sectors per track : "&.sectorspertrack&"kb"
end if
wnl "  partitions : "&.partitions
wnl "  size : "&sizeformat(.size)
end with
next
str="  volume"+space(2)+"type"+space(8)+"format"+space(4)
str=str+"size"+space(6)+"free"+space(12)+"label"
wnl str
for each obj8 in col8
with obj8
drivetype=""
select case .drivetype
case 0
   drivetype="unknow"
case 1
   drivetype="norootdir"
case 2
   drivetype="removable"
case 3
   drivetype="fixed"
case 4
   drivetype="network"
case 5
   drivetype="cd-rom"
case 6
   drivetype="ram"
end select
strpercent=""
if .size<>"" and .freespace<>"" then
strpercent=" ("&formatpercent(.freespace/.size,0)&")"
end if
str="  "&wsp(.caption,8)&wsp(drivetype,12)&wsp(.filesystem,10)&wsp(sizeformat(.size),10)
str=str&wsp(sizeformat(.freespace)&strpercent,16)&.volumename
wnl str
end with
next

wnl vbcrlf&"nic informaton :"
for each obj9 in col9
with obj9
if .ipenabled then
wnl "  index : "&.index
wnl "  description : "&.description
if viewtype=1 then
wnl "  dhcp enabled : "&.dhcpenabled
wnl "  dhcp server : "&.dhcpserver
wnl "  dns host name : "&.dnshostname
wnl "  dns server search order : "&wfl(.dnsserversearchorder)
wnl "  wins primary server : "&.winsprimaryserver
end if
wnl "  ip address : "&wfl(.ipaddress)
wnl "  mac address : "&.macaddress
wnl "  default ip gateway : "&wfl(.defaultipgateway)
wnl "  ip subnet : "&wfl(.ipsubnet)
if viewtype=1 then
wnl "  ip filter security enabled : "&.ipfiltersecurityenabled
wnl "  ipsec permit ip protocols : "&wfl(.ipsecpermitipprotocols)
wnl "  ipsec permit tcp ports : "&wfl(.ipsecpermittcpports)
wnl "  ipsec permit udp ports : "&wfl(.ipsecpermitudpports)
end if
end if
end with
next

if viewtype=1 then
wnl vbcrlf&"hot fixes info :"
for each obj10 in col10
wnl "  hot fix id : "&obj10.hotfixid
wnl "  fix comments : "&obj10.fixcomments
wnl "  install date : "&obj10.installdate
wnl "  service pack in effect : "&obj10.servicepackineffect
next
end if

if program=1 then
wnl vbcrlf&"applications :"
hklm=&h80000002
keypath="software\microsoft\windows\currentversion\uninstall\"
obj11.enumkey hklm,keypath,keyarray
redim str(ubound(keyarray)+1)
j=0
for i=0 to ubound(keyarray)
   obj11.getstringvalue hklm,keypath+keyarray(i),"displayname",strvalue
   if strvalue<>"" then
   str(j)=strvalue
   j=j+1
   end if
next
if j>1 then
for i=0 to j-1
   for k=0 to j-i-1
      if strcomp(str(k),str(k+1),1)=1 then
     strtemp=str(k+1)
     str(k+1)=str(k)
     str(k)=strtemp
      end if
   next
next
end if
for i=0 to j-1
   wnl "  "&str(i)
next
end if

sub showerr()
if err.number then
   wscript.echo "error 0x"&cstr(hex(err.number))&" ."
   if err.description<>"" then
      wscript.echo "error description: "&err.description&"."
   end if
   wscript.quit
end if
end sub

sub wnl(msg)
wscript.echo msg
if isobject(of) then
   on error resume next
   of.writeline msg
   showerror()
   on error goto 0
end if
end sub

function wfl(byref obj)
str=""
for i=0 to ubound(obj)
   str=str&obj(i)&" "
next
wfl=str
end function

function wsp(msg,num)
if msg<>"" then
   msg=left(msg,num-1)
   wsp=msg&space(num-len(msg))
else
   wsp=space(num)
end if
end function

function timeformat(msg)
timeformat=left(msg,4)&"/"&mid(msg,5,2)&"/"&mid(msg,7,2)&" "&mid(msg,9,2)&":"&mid(msg,11,2)&":"&mid(msg,13,2)
end function

function sizeformat(msg)
if msg<>"" then
size=msg/1048576
if size>1024 then
  sizeformat=round(size/1024,2)&"gb"
else
  sizeformat=round(size,1)&"mb"
end if
end if
end function

function objget(msg)
set col=objswb.instancesof(msg)
for each objx in col
   set obj=objx
next
set objget=obj
end function

function usage()
wscript.echo string(79,"*")
wscript.echo "rgis v1.03"
wscript.echo "remote get infomation script, by zzzevazzz"
wscript.echo "welcome to visite www.isgrey.com & www.h4h4.com"
wscript.echo "usage:"
wscript.echo "cscript rgis.vbs [/r targetip username password] [/o filename] [/v] [/a] [/h]"
wscript.echo "/r: remote get info."
wscript.echo "/o: output to file."
wscript.echo "/v: get more infomation."
wscript.echo "/a: get applications infomation."
wscript.echo "/h: show usage."
wscript.echo string(79,"*")&vbcrlf
end function