/ Forside / Teknologi / Udvikling / VB/Basic / Nyhedsindlæg
Login
Glemt dit kodeord?
Brugernavn

Kodeord


Reklame
Top 10 brugere
VB/Basic
#NavnPoint
berpox 2425
pete 1435
CADmageren 1251
gibson 1230
Phylock 887
gandalf 836
AntonV 790
strarup 750
Benjamin... 700
10  tom.kise 610
Oplysninger om PC i tekst fil
Fra : Nyheder


Dato : 17-07-08 03:58

Hej NG

Jeg har allerede en bat med efterfølgende vbs fil der kan give mig
flere af oplysningerne.

Det jeg mangler er at der også kommer de sidste (gerne 2 eller 3) der
har være logget på PC'en (deres brugernavn)

Kan man på nogen måde få det lavet så der kun er én fil og ikke to?

Hilsen

Sten

Bat:
cscript pcinfo.vbs > %computername%.txt

vbs filen:
' ********************************
' Udskriv standardoplysninger om PC
' - udskrives til .txt-fil
' ---------------------------------------
' Forfatter: Klaus Jørgensen i dk.edb.hardware 11.9.07
' ********************************
'
' Køres med fx:
' cscript pcinfo.vbs > %computername%_%date%.txt

Function CnvDate(pDate)
CnvDate = CDate(Mid(pDate, 7, 2) & "/" & _
Mid(pDate, 5, 2) & "/" & Left(pDate, 4) _
& " " & Mid (pDate, 9, 2) & ":" & _
Mid(pDate, 11, 2) & ":" & Mid(pDate, _
13, 2))
End Function

On Error Resume Next
Set SWBemlocator = CreateObject("WbemScripting.SWbemLocator")
Set objWMIService = SWBemlocator.ConnectServer(".","\root\CIMV2")

Set colSettings = objWMIService.ExecQuery("SELECT * FROM
Win32_ComputerSystem",,48)
For Each objComputer In colSettings
Result=objComputer.Name
Wscript.Echo "Host: " & objComputer.Name
Wscript.Echo "Manufacturer: " & objComputer.Manufacturer
Wscript.Echo "Model: " & objComputer.Model
Next
Set colItems = objWMIService.ExecQuery("Select * from
Win32_BaseBoard",,48)
For Each objItem In colItems
Wscript.Echo "Product: " & objItem.Product
Next

Set colItems = objWMIService.ExecQuery("Select * from Win32_BIOS",,48)
For Each objItem In colItems
Wscript.Echo "Username: " & objItem.username
Next

Set colItems = objWMIService.ExecQuery("Select * from Win32_BIOS",,48)
For Each objItem In colItems
Wscript.Echo "SerialNumber: " & objItem.SerialNumber
Next

Set colItems = objWMIService.ExecQuery("Select * from
Win32_Processor",,48)
TotalCPU = 0
strCPU = ""
For Each objItem In colItems
strCPU = Trim(objItem.Name)
TotalCPU = TotalCPU + 1
Next

If TotalCPU>0 Then Wscript.Echo "CPU: " & TotalCPU & " * " & strCPU

Set colItems = objWMIService.ExecQuery("Select * from
Win32_PhysicalMemory where MemoryType<>11",,48)
TotalMemory = 0
s = ""
For Each objItem In colItems
If s<>"" Then s = s & "+"
s = s & objItem.Capacity / 1024^2 & "Mb"
TotalMemory = TotalMemory + objItem.Capacity
Next
If TotalMemory>0 Then Wscript.Echo "Memory: " & TotalMemory / 1048576
& "Mb (" & s & ")"

Set colDiskDrives = objWMIService.ExecQuery("SELECT * FROM
Win32_DiskDrive",,48)
TotalDisk = 0
s = ""
For each objItem In colDiskDrives
If s<>"" Then s = s & "+"
s = s & Round(objItem.Size / 1024^3) & "Gb"
TotalDisk = TotalDisk + Round(objItem.Size / 1024^3)
Next
If TotalDisk>0 Then Wscript.Echo "Disk Size: " & TotalDisk & "Gb (" &
s & ")"

Set colOperatingSystems = objWMIService.ExecQuery("Select * from
Win32_OperatingSystem")
For Each objOperatingSystem in colOperatingSystems
Wscript.Echo objOperatingSystem.Caption & " " &
objOperatingSystem.Version
Next

Set IPConfigSet = objWMIService.ExecQuery("Select
IPAddress,DefaultIPGateway,IPSubnet from
Win32_NetworkAdapterConfiguration ")
For Each IPConfig in IPConfigSet
   If Not IsNull(IPConfig.IPAddress) Then
      For i=LBound(IPConfig.IPAddress) to UBound(IPConfig.IPAddress)
         WScript.Echo "IP Address: " & IPConfig.IPAddress(i)
         WScript.Echo "IP Gateway: " & IPConfig.DefaultIPGateway(i)
         WScript.Echo "IP Subnet: " & IPConfig.IPSubnet(i)
      Next
   End If
Next

Set colItems = objWMIService.ExecQuery("SELECT * FROM
Win32_NetworkAdapterConfiguration where IPEnabled=TRUE",,48)
For Each objItem in colItems
Wscript.Echo "IPSubnet: " & objItem.IPSubnet
Next

 
 
Nyheder (17-07-2008)
Kommentar
Fra : Nyheder


Dato : 17-07-08 05:10

Jeg har fået den bruger der er logget på maskinen med i min vbs, men
kan man få de sidste 2 - 3 brugere der har været logget ind?

Og fortsat kan man lave ed 2 filer i én fil?

Sten

vbs:

Sub InfoFromNetWork
Dim objNet
On Error Resume Next
Set objNet = CreateObject("WScript.NetWork")
If Err.Number <> 0 Then 'If error occured then display
notice
Wscript.Echo "***Error: Cannot get username"
Else
Wscript.Echo "User Name: " & objNet.UserName
Wscript.Echo "Computer Name: " & objNet.ComputerName
Wscript.Echo "Domain Name: " & objNet.UserDomain
End if
Set objNet = Nothing
End Sub

Søg
Reklame
Statistik
Spørgsmål : 177558
Tips : 31968
Nyheder : 719565
Indlæg : 6408914
Brugere : 218888

Månedens bedste
Årets bedste
Sidste års bedste