kev_147 Posted August 15, 2006 Share Posted August 15, 2006 I don't know if you have seen the news today about Dell recalling millions of laptop batteries. Article can be found here:http://news.bbc.co.uk/1/hi/business/4793143.stmI have been tasked with writing a script that will determine if the PC/Laptop is Windows XP as I think WMI is only installed on WinXP and above, (might be wrong)If it is WinXP, it will then launch a vbs script that will collect information such as:I need to put a check for checking if machine is a laptop or desktop, if laptop continue running script, if desktop quit. (any assistance with this appreciated)ComputernameUsernameOS CaptionOS VersionLaptop ManufacturerLaptop ModelBattery ManufacturerBattery NameBattery Device IDAll of this information is outputted to a file called %computername%.txt and thn a copy of this file is made to %Temp%I am having a problem where if the vbscript is run once and the %computername%.txt file doesn't already exisit, I get a permission denied error. (It creates the .txt file, but doesn't enter any information). However if I then run the vbscript again with the .txt file already created, it works fine. Can someone tll me what I am doing wrong cos it is really bugging me.It hasn't been decided how this script is going to b launched yet, but I am 99% certain it will be kicked off by Kix login scripts. Is there a way for th batch file that Kix launches to determine whether or not machine is laptop or desktop? I think there is a WMI command line engine, but can't remember exactly.Once we have collected all these %computername%.txt files accross the council, we then would like to import all of these files into 1 csv file. From this file we will then try and determine exactly what customrs need to be contacted to arrange replacement battries. I can't beleive there isn't a solution for this from Dell. I know they have a webpage, but that relies on the person having access to the internet. I was hoping that a WMI script could find out the serial number of the battery, but it appears not to drill down that far.DellReplacement.zip Link to comment Share on other sites More sharing options...
LLXX Posted August 16, 2006 Share Posted August 16, 2006 I doubt it is possible to obtain the serial number of the battery through software, you have to remove it and physically look at it. Link to comment Share on other sites More sharing options...
gamehead200 Posted August 16, 2006 Share Posted August 16, 2006 You would save loads of time just removing the battery manually... It's not that hard actually... We checked quite a few laptops today within a few minutes! The older ones might have blown up if we hadn't! Link to comment Share on other sites More sharing options...
kev_147 Posted August 16, 2006 Author Share Posted August 16, 2006 The problem we have got is that there are over 5000 users and we don't know exactly who has and where th laptops are located.I know you can't get the battery serial number through WMI, but you can gather information that will allow you to cut down the amount of machines that may need replacement. Thats the idea of this script.I would much rather go round 200 users to see if they need a replacement, rather than 5000+. It should save a lot of time running this script, I really just want to know, why I have to run it twice to get the text file to populate. Link to comment Share on other sites More sharing options...
imric Posted August 16, 2006 Share Posted August 16, 2006 Hi Kev, I've had a quick glance at the script code (quick as I'm a little ill today and don't want to do any head work ). From what I can see the problem is when your checking for the file to exist.' Check that the strFile FileexistsIf objFSO.FileExists(strDirectory & strFile) Then Set objFile = objFSO.GetFile(strDirectory & strFile)Else Set objFile = objFSO.CreateTextFile(strDirectory & strFile, True)End IfYour checking for the file to exist... if it exists it connects to the file, if it doesnt exist it creates the file... and that's it. It doesnt connect to it once its created the file.I could be wrong though :| like i said I'm not at 100% today Link to comment Share on other sites More sharing options...
kev_147 Posted August 16, 2006 Author Share Posted August 16, 2006 Thanks for the feedback. Especially if you aren't feeling 100%.I have just finished off restructuring the .vbs file. I have followed the same structure that GSM used in the oeminfo.ini post. All credit goes to GSM. You the Man!! I am not 100% sure what in the attached file has fixed the error with it not writing the information to file the 1st time round, so if anyone can explain to me for future reference that would be good.I just need to add a check in the vbs file that determines whether it is a laptop or not. If System=Laptop then continue else end script. I will repost when I have worked this out.Change attachment to .vbsDellBattery.txt Link to comment Share on other sites More sharing options...
gunsmokingman Posted August 16, 2006 Share Posted August 16, 2006 This may help you figure out what type of computer it is.strComputer = "." Set objWMI = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") Set colChassis = objWMI.ExecQuery("Select * from Win32_SystemEnclosure") For Each objChassis in colChassis For Each objItem in objChassis.ChassisTypes If objItem = 3 Then Wscript.Echo "Desktop" End If If objItem = 9 Then Wscript.Echo "Laptop" End If Next NextHere is a Link for more information Link to comment Share on other sites More sharing options...
tarquel Posted August 17, 2006 Share Posted August 17, 2006 hehe Kev, you don't work for Powys do you?If so, give me a shout privately We've got a Dell laptop from the county that I had best check when school starts again.CheersNath. Link to comment Share on other sites More sharing options...
stevenkan Posted August 29, 2006 Share Posted August 29, 2006 I am using a script at logon that pops up a message box if it matches the Serial number obtained through WMI against the known types in the list issued by Dell.SteveDellRecallTest.txt Link to comment Share on other sites More sharing options...
mitsu Posted August 30, 2006 Share Posted August 30, 2006 (edited) Really good script Steve , nice scriptthanks Mitsu Edited August 30, 2006 by mitsu Link to comment Share on other sites More sharing options...
kev_147 Posted August 30, 2006 Author Share Posted August 30, 2006 Steve does that script actually get the serial number of the battery? I didn't think WMI could obtain the actual serial number of the battery, only the model number Link to comment Share on other sites More sharing options...
stevenkan Posted August 31, 2006 Share Posted August 31, 2006 It doesn't return the full serial number, but does get enough digits to match against the recall listing that Dell have published. I have tried it on known good and bad batteries that I have and it works fine for me.As an extra, here is a list of the objects and some example outputs from the WMI PortableBattery class. The Name object has the 5 digits that need to be matched, else you could just match the manufacturer against Sony and then escalate up your support process as required. PS this was a good battery!Availability: BatteryStatus: CapacityMultiplier: 10Caption: Portable BatteryChemistry: 2ConfigManagerErrorCode: ConfigManagerUserConfig: CreationClassName: Win32_PortableBatteryDescription: Portable BatteryDesignCapacity: 52170DesignVoltage: 11100DeviceID: Portable Battery 0ErrorCleared: ErrorDescription: EstimatedChargeRemaining: EstimatedRunTime: ExpectedLife: FullChargeCapacity: LastErrorCode: Location: Sys. Battery BayManufactureDate: Manufacturer: Panasonic MaxBatteryError: 2MaxRechargeTime: Name: DELL 4M010 4 PNPDeviceID: PowerManagementCapabilities: PowerManagementSupported: SmartBatteryVersion: 1.0Status: StatusInfo: SystemCreationClassName: Win32_ComputerSystemSystemName: PC2141TimeOnBattery: TimeToFullCharge: Link to comment Share on other sites More sharing options...
kev_147 Posted August 31, 2006 Author Share Posted August 31, 2006 Thats similar to how we are doing it at work. I will post my final code tomorrow as I have been off work.Basically we obtain the information and write details of the laptop where the battery may need replacing and output this to a text file on a network share. We then a simple batch file to merge out that information into 1 csv file, where we can then search for make of battery first and then the model number if WMI gets this info. We found that there was a few laptops, i think the Latitude X300 where WMI didn't return anything regarding model number. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now