Von |
Inspirion |
eMail |
|
Am |
07. Oktober 2008 um 12:23:05 |
Frage |
Hallo,
habe mir ein VBS script heruntergeladen welches aus einer LOG Datei die Restlaufzeit des Akkus auslesen soll.
Bekomme leider immer folgende Fehlermeldung
[Error] Typen unverträglich: '[string: ", , "]' In batmonread.vbs (LaptopTimeLeft) Line 47, column 1
Hier mal das Script:'######################################################## ################################## '# BATMONREAD.VBS [beta] For Samurize - (C) 2004 by nashxgi - For free use - # '# This script will retrieve the seconds remaining For the systems # '# battery Until it Is flat out of the logfile created by the battery monitoring tool # '# "Battery Monitor" from Passmark Corp. www.passmark.com . # '# INSTALL AND RUN IT BEFORE USING THIS SCRIPT ! # '# The Function LaptopTimeLeft() will deliver 3 possible stati To Samurize: # '# 1- The expected leftover time In hrs:mins calculated from the seconds measured # '# 2- In Case Battery Monitor does Not deliver useful data, Samurize gets a "No Status" # '# message. This changes when data Is received again from the BM-log. # '# 3- In Case that leftover time Is less than 10 mins the script will deliver a "Warning"# '# message indicating that battery power Is very low. # '# # '# Setting the script: # '# 1- Set the current path To the BATTERY MON logfile In Line 28. # '# 2- If needed reset the MINS value For sending a warning-message In Line 57. # '######################################################## ################################## Option Explicit Const ForReading = 1 Dim sFileName Dim Feld(1) Dim fso, oText Dim i,std, min,y Dim AnyString, MyStr,strTime Dim bCreate sFileName = "C:\Programme\Batterymon\batterymonlog.txt" '// ADD PATH TO BATTERYMON LOG-FILE HERE bCreate = False i=0 Set fso = CreateObject("Scripting.FileSystemObject") Set oText = fso.OpenTextFile(sFileName, ForReading, bCreate) Do Until oText.AtEndofStream Feld(0)=oText.ReadLine Feld(1)=Feld(0) Loop oText.Close AnyString = Feld(1) MyStr = Right(AnyString, 4) If MyStr=", -1" Then strTime="No Status" Else i=int(MyStr) y=i/60 std=int(y/60) min=y Mod 60 If std <> 0 Then If min < 10 Then min = "0" & min strTime = std& " : " & min & " left" Else strTime = std& " : " & min & " left" If min < 10 Then '// SET THE MINS-VALUE TO SEND A WARNING-MSG (Default Is 10) strTime="W A R N I N G !" End IF End If End If Function LaptopTimeLeft() LaptopTimeLeft=strTime End Function Auzug aus der Logdatei2008-10-07, 10:50:54, OK, 30%, 4.58, 4951, 0, , 10.80, 0, 30.0%, , , , , , , , , , , , |
|