Avatar billede mibu Nybegynder
03. februar 2011 - 09:16 Der er 8 kommentarer og
1 løsning

Hjælp til en bat fil

Jeg har aldrig rigtigt arbejdet med bat filer før, så jeg håber nogen kan hjælpe.

Jeg skal bruge en bat fil der kan finder en given pc's processor hastighed og ram størrelse, og som luxus må den meget gerne automatisk sende infomationen til en mailadresse. (Som notepad fil kan også bruges)

Er der nogen der lige har sådan en størrelse på lager ?
03. februar 2011 - 09:22 #1
Du skal altid skrive under hvilket Styresystem!
Win98, ME, W2000, XP, Vista, Win7, OS/2, Unix, Linux, ... ?
Avatar billede jakobdo Ekspert
03. februar 2011 - 09:30 #2
Måske du kunne samle noget fra: http://www.activexperts.com/activmonitor/windowsmanagement/adminscripts/computermanagement/hardware/
Godt nok ikke bat, men det kan afvikles på windows, hvilket jeg gætter du anvender.
Avatar billede mibu Nybegynder
03. februar 2011 - 10:04 #3
karise_larry - Win XP
jakobdo - det er noget omfattende, bare for to oplysninger(cpu/ram)
Avatar billede jakobdo Ekspert
03. februar 2011 - 10:08 #4
mibu: Jamen jeg beklager da meget, at jeg ikke lavede et fungerende script til dig.
Det skal jeg aldrig glemme igen.
Troede jo du var villig til selv at klippe og klistre.
Men du får da bare et script her:

strComputer = "."
Set objWMIService = GetObject("winmgmts:"
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colSettings = objWMIService.ExecQuery _
    ("Select * from Win32_ComputerSystem")
For Each objComputer in colSettings
    Wscript.Echo "Total Physical Memory: " & _
        objComputer.TotalPhysicalMemory
Next
Set colSettings = objWMIService.ExecQuery _
    ("Select * from Win32_Processor")
For Each objProcessor in colSettings
    Wscript.Echo "System Type: " & objProcessor.Architecture
    Wscript.Echo "Processor: " & objProcessor.Description
Next

Og ja, beklager meget, undskyld.
Avatar billede mibu Nybegynder
03. februar 2011 - 10:19 #5
:-) mange tak! Jeg vil da ellers meget gerne klippe/klister, men som jeg skrev øverst i mit spørgsmål, så har jeg ikke rigtigt prøvet det her før, så jeg ved ikke hvor jeg skal klippe og hvad jeg skal klister.
Hvis der var webcam på min pc ville du nu kunne se mig bukke dybt.
Mange tak

Jeg kaster mig lige ud i at prøve det af. Venligst læg et svar.
03. februar 2011 - 11:03 #6
Som 'dum' *.CMD fil ->



@echo off
dxdiag /t %TEMP%\dxdiag.txt
type %TEMP%\dxdiag.txt | find "Processor: "> %TEMP%\Result.txt
type %TEMP%\dxdiag.txt | find "  Memory: ">> %TEMP%\Result.txt
type %TEMP%\Result.txt
pause


Det ka' du jo evt. bygge videre på ...
Avatar billede jakobdo Ekspert
03. februar 2011 - 11:07 #7
Og denne del kan sende en email:

Set objMessage = CreateObject("CDO.Message")
objMessage.Subject = "Example CDO Message"
objMessage.From = "me@my.com"
objMessage.To = "test@paulsadowski.com"
objMessage.TextBody = "This is some sample message text."
objMessage.Send

Fundet her: http://www.paulsadowski.com/wsh/cdo.htm
Avatar billede -Lizard- Nybegynder
03. februar 2011 - 12:58 #8
Hej Karise_larry.

Jeg bruger selv denne kode via logon i domæne.
Det er lavet i VBscript. Der kan du håndtere alle tingene på en gang. Koden er lavet til at sende oplysninger for den PC den bliver kørt på.
Kopiere indholdet her fra og sæt det ind i en tom fil, med .VBS endelse. Ret derefter Mail oplysninger i den sidste funktion så de passer til din mailserver.

Kald din fil med cscript DinFil.vbs
Så skulle det gerne virke for dig...

---SNIP----

'On Error Resume Next
strOut = ""
Set wshNetwork = WScript.CreateObject( "WScript.Network" )
strComputer = wshNetwork.ComputerName
GetBiosInfo(strOutComputer)
ShowProcessorInfo(strComputer)
GetMemInfo(strOutCompute)
Call SendMail(strOut, strComputer)
Set wshNetwork = Nothing

Function ShowProcessorInfo(strComputer)
    strOut = strOut &"------------------------------------------------------" &VbNewLine
    strOut = strOut &"---------------------------CPU------------------------" &VbNewLine
    strOut = strOut &"------------------------------------------------------" &VbNewLine
    Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
    Set colItems = objWMIService.ExecQuery("Select * from Win32_Processor")
    For Each objItem in colItems
        strOut = strOut &"Address Width: " &objItem.AddressWidth &VbNewLine
        strOut = strOut &"Architecture: " &objItem.Architecture &VbNewLine
        strOut = strOut &"Availability: " &objItem.Availability &VbNewLine
        strOut = strOut &"CPU Status: " &objItem.CpuStatus &VbNewLine
        strOut = strOut &"Current Clock Speed: " &objItem.CurrentClockSpeed &VbNewLine
        strOut = strOut &"Data Width: " &objItem.DataWidth &VbNewLine
        strOut = strOut &"Description: " &objItem.Description &VbNewLine
        strOut = strOut &"Device ID: " &objItem.DeviceID &VbNewLine
        strOut = strOut &"Ext Clock: " &objItem.ExtClock &VbNewLine
        strOut = strOut &"Family: " &objItem.Family &VbNewLine
        strOut = strOut &"L2 Cache Size: " &objItem.L2CacheSize &VbNewLine
        strOut = strOut &"L2 Cache Speed: " &objItem.L2CacheSpeed &VbNewLine
        strOut = strOut &"Level: " &objItem.Level &VbNewLine
        strOut = strOut &"Load Percentage: " &objItem.LoadPercentage &VbNewLine
        strOut = strOut &"Manufacturer: " &objItem.Manufacturer &VbNewLine
        strOut = strOut &"Maximum Clock Speed: " &objItem.MaxClockSpeed &VbNewLine
        strOut = strOut &"Name: " &objItem.Name &VbNewLine
        strOut = strOut &"PNP Device ID: " &objItem.PNPDeviceID &VbNewLine
        strOut = strOut &"Processor Id: " &objItem.ProcessorId &VbNewLine
        strOut = strOut &"Processor Type: " &objItem.ProcessorType &VbNewLine
        strOut = strOut &"Revision: " &objItem.Revision &VbNewLine
        strOut = strOut &"Role: " &objItem.Role &VbNewLine
        strOut = strOut &"Socket Designation: " &objItem.SocketDesignation &VbNewLine
        strOut = strOut &"Status Information: " &objItem.StatusInfo &VbNewLine
        strOut = strOut &"Stepping: " &objItem.Stepping &VbNewLine
        strOut = strOut &"Unique Id: " &objItem.UniqueId &VbNewLine
        strOut = strOut &"Upgrade Method: " &objItem.UpgradeMethod &VbNewLine
        strOut = strOut &"Version: " &objItem.Version &VbNewLine
        strOut = strOut &"Voltage Caps: " &objItem.VoltageCaps &VbNewLine
    Next
    Set objWMIService = Nothing
    Set colItems = Nothing
    'ShowProcessorInfo = strOut
End Function

Function GetMemInfo(strOutCompute)
    Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
    Set colComputerSystem = objWMIService.ExecQuery("Select * from Win32_PhysicalMemory")
    strOut = strOut &"------------------------------------------------------" &VbNewLine
    strOut = strOut &"--------------------------MEM-------------------------" &VbNewLine
    strOut = strOut &"------------------------------------------------------" &VbNewLine
    strOut = strOut & "************************************************" &VbNewLine
    strOut = strOut & "* Fysik om hukommelsen!                        *" &VbNewLine
    strOut = strOut & "************************************************" &VbNewLine
    strOut = strOut & "" &VbNewLine
    For Each objComputerSystem in colComputerSystem
        strOut = strOut & "BankLabel " &objComputerSystem.BankLabel &VbNewLine
        strOut = strOut & "Capacity " &objComputerSystem.Capacity &VbNewLine
        strOut = strOut & "Caption " &objComputerSystem.Caption &VbNewLine
        strOut = strOut & "CreationClassName " &objComputerSystem.CreationClassName &VbNewLine
        strOut = strOut & "DataWidth " &objComputerSystem.DataWidth &VbNewLine
        strOut = strOut & "DeviceLocator " &objComputerSystem.DeviceLocator &VbNewLine
        strOut = strOut & "FormFactor " &objComputerSystem.FormFactor &VbNewLine
        strOut = strOut & "MemoryType " &objComputerSystem.MemoryType &VbNewLine
        strOut = strOut & "Model " &objComputerSystem.Model
        strOut = strOut & "PositionInRow " &objComputerSystem.PositionInRow &VbNewLine
        strOut = strOut & "SerialNumber " &objComputerSystem.SerialNumber &VbNewLine
        strOut = strOut & "SKU " &objComputerSystem.SKU &VbNewLine
        strOut = strOut & "Speed " &objComputerSystem.Speed &VbNewLine
        strOut = strOut & "Status " &objComputerSystem.Status &VbNewLine
        strOut = strOut & "Tag " &objComputerSystem.Tag &VbNewLine
        strOut = strOut & "TotalWidth " &objComputerSystem.TotalWidth &VbNewLine
        strOut = strOut & "TypeDetail " &objComputerSystem.TypeDetail &VbNewLine
        strOut = strOut & "Version " &objComputerSystem.Version &VbNewLine
        strOut = strOut & "************************************************" &VbNewLine
        strOut = strOut & "" &VbNewLine
        strOut = strOut & ""      &VbNewLine
    Next
    strOut = strOut & "************************************************" &VbNewLine
    strOut = strOut & "* Usage?!                                      *" &VbNewLine
    strOut = strOut & "************************************************" &VbNewLine
    strOut = strOut & "" &VbNewLine
    Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
    Set objMemory = objWMIService.ExecQuery ("Select * from Win32_OperatingSystem")
    For Each obj in objMemory
        strOut = strOut & "Total RAM "&(obj.TotalVisibleMemorySize / 1024)&" MB" &VbNewLine
        strOut = strOut & "Tilgængelige RAM "&(obj.FreePhysicalMemory /1024)&" MB" &VbNewLine
        strOut = strOut & "RAM i brug "&((obj.TotalVisibleMemorySize-obj.FreePhysicalMemory)/1024)&" MB" &VbNewLine
        strOut = strOut & ((obj.TotalVisibleMemorySize-obj.FreePhysicalMemory) / obj.TotalVisibleMemorySize * 100) &" % i brug" &VbNewLine
    Next
    Set objWMIService = Nothing
    Set objMemory = Nothing
End Function


Function GetBiosInfo(strOutComputer)
    Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
    Set colBIOS = objWMIService.ExecQuery ("Select * from Win32_BIOS")
   
    For each objBIOS in colBIOS
        strOut = strOut &"------------------------------------------------------" &VbNewLine
        strOut = strOut &"------------------------BIOS--------------------------" &VbNewLine
        strOut = strOut &"------------------------------------------------------" &VbNewLine
        strOut = strOut &"Build Number: " & objBIOS.BuildNumber &VbNewLine
        strOut = strOut &"Current Language: " & objBIOS.CurrentLanguage &VbNewLine
        strOut = strOut &"Installable Languages: " & objBIOS.InstallableLanguages &VbNewLine
        strOut = strOut &"Manufacturer: " & objBIOS.Manufacturer &VbNewLine
        strOut = strOut &"Name: " & objBIOS.Name &VbNewLine
        strOut = strOut &"Primary BIOS: " & objBIOS.PrimaryBIOS &VbNewLine
        strOut = strOut &"Release Date: " & objBIOS.ReleaseDate &VbNewLine
        strOut = strOut &"Serial Number: " & objBIOS.SerialNumber &VbNewLine
        strOut = strOut &"SMBIOS Version: " & objBIOS.SMBIOSBIOSVersion &VbNewLine
        strOut = strOut &"SMBIOS Major Version: " & objBIOS.SMBIOSMajorVersion &VbNewLine
        strOut = strOut &"SMBIOS Minor Version: " & objBIOS.SMBIOSMinorVersion &VbNewLine
        strOut = strOut &"SMBIOS Present: " & objBIOS.SMBIOSPresent &VbNewLine
        strOut = strOut &"Status: " & objBIOS.Status &VbNewLine
        strOut = strOut &"Version: " & objBIOS.Version &VbNewLine
    Next
    Set objWMIService = Nothing
    Set colBIOS = Nothing
End Function



Function SendMail(strInfo, strComputer)
    Set objEmail = CreateObject("CDO.Message")
    objEmail.From = "AFSENDER ADRESSE"
    objEmail.To = "MODTAGER"
    objEmail.Subject = strComputer &" HW INFO!" 
    objEmail.Textbody = strInfo
    objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
    objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "DIN MAIL SERVER"
    objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
    objEmail.Configuration.Fields.Update
    objEmail.Send
    Set objEmail = Nothing
End Function


---SNAP---

/-Lizard-
Avatar billede mibu Nybegynder
21. marts 2011 - 18:51 #9
Lukker
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Kurser inden for grundlæggende programmering

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester