Need help creating full battery alert using visual basic script

Hi,
I have been searching for resources, programs and code that will create an alert for me to unplug my charger when my laptop
battery is charged to full (or almost full).
The only problem with this code is that
Line 13: iRemaining (or RemainingCapacity called from BatteryStatus returns a 0 (might be a floating point which I can't figure out why). I even checked the microsoft documentation and its supposed to be a percentage.
I want to get either the current percentage of the battery or the total Fullchargedcapacity and the EstimatedRemainingCapacity to find the % of battery level.
Essentially what I am asking is how can I return the battery % using visual basic script.
Help!
The Code:
1 set oLocator = CreateObject("WbemScripting.SWbemLocator")
2 set oServices = oLocator.ConnectServer(".","root\wmi")
3 set oResults = oServices.ExecQuery("select * from batteryfullchargedcapacity")
4 for each oResult in oResults iFull = oResult.FullChargedCapacity
5 next
6
7 while (1)
8 set oResults = oServices.ExecQuery("select * from batterystatus")
9 for each oResult in oResults
10 iRemaining = oResult.RemainingCapacity
12 bCharging = oResult.Charging
12 next
13 iPercent = ((iRemaining / iFull) * 100) mod 100
14 if bCharging and (iPercent > 95) Then msgbox "Battery is at " & iPercent "%",vbInformation,"Battery monitor"
15 wscript.sleep 30000 ' (30 seconds)
16 wend

14 if bCharging and (iPercent > 95) Then msgbox "Battery is at " & iPercent "%",vbInformation,"Battery monitor"
On my Windows 7 machine your script returns the desired percentage (after adding the missing "&" to the right of "iPercent" in Line 14).

Similar Messages

  • I need to create  .pst  ext . file using java,whi will import in ms outlook

    {color:#ff0000}*I need to create .PST extension file using java which will be able to import in ms outlook,and that .pst file will contain root folder (like Personal Folders) and inbox,sent mail*{color}
    give me some hint It is essential task .we have to implement code in  java

    I'm using the thin drivers.
    The answer to your question is no, you do not need to create a DSN to connect to Oracle. The Oracle thin driver is all that is required. Your code looks OK to me, I'm assuming that you xxx'd out the IP, and that you are using a real IP in the actual code.
    The message you got back is pretty generic, but can indicate that the Oracle database listener isn't available. Perhaps the database is on a different port, or perhaps the listerner isn't running. Perhaps you have the IP address wrong.
    So, to be very basic:
    1) Can you ping the server you are trying to connect to? This makes sure you are using a valid IP address.
    2) Can you connect to the Oracle server from an Oracle client? This makes sure the listener is running properly, and that you know the correct port number and login information (The port number could be in a local or server based TNS file, or available through an Oracle names server. You might try using the program tnsping if it is available on the client for validation.
    3) If you can do 1 and 2, then be sure you are using the same connection parameters (server, port userid and password) that worked with 2.
    4) Verify that you are using (pointing to) the correct set of Oracle classes for the thin connection. This can be tricky if you have different versions of Oracle on the client then on the server, but is documented on the Oracle website.
    5) If everything checks out, you might want to verify that you are using the most recent versions of the thin drivers, including the Oracle patches.
    Hope it helps - good luck,
    Joel

  • Uber Noob Needs Help Creating website!

    I need help creating my webpage: It has a textbox on it were
    the user enters a URL and it then redirects the end user to that
    URL when they press the GO Button. It also has a check box saying
    "Hide my IP", If the end user clicks this box and then clicks go
    they will be directed to the website they stateted in the Textbox
    but this time it shall mask there IP Address so they can bypass
    proxys and surf anonomosly. Please can someone give me some HTML
    code i could use for this site or a Link to a website that can give
    me the code.

    I assume the application is connecting to Oracle using an application ID/password. If so, check to see if that user has a private synonyn to the table. If so drop it since you have a public synonym.
    Verify that the public synonym is in fact correct. Drop and recreate the public synonym if you cannot select against the synonym name using an ID that can perform select * from inhouse.icltm where rownum = 1. That is if this other user cannot issue select * from icltm where rownum = 1 without an error.
    Check that the application ID has the necessary object privileges on the table.
    Queries you need
    select * from dba_synonyms
    where table_owner = 'INHOUSE'
    and table_name = 'ICLTM'
    You may find both public and private synonms. Either fix or delete. (Some may reference someelses.icltm table if one exists)
    select * from dba_tab_privs
    where table_name = 'ICLTM'
    and owner = 'INHOUSE'
    Note - it is possible to create mixed case or lower case object names in Oracle by using double quotes around the name. Do not do this, but do look to see that this was not done.
    You could also query dba_objects for all object types that have the object_name = 'ICLTM'
    HTH -- Mark D Powell --

  • Create SharePoint 2013 workflow using visual studio 2013

    Dear Team,
    How  to create a workflow for template approval process using visual studio 2013.To achieve this do i need to install share point on my machine.

    Hi,
    According to your post, my understanding is that you want to create a SharePoint 2013 workflow using Visual Studio 2013.
    We need setting up and configuring Microsoft SharePoint Server 2013 and the Workflow Manager Client 1.0 server, see Start:
    Set up and configure SharePoint 2013 Workflow Manager.
    The following materials for your reference:
    Develop SharePoint 2013 workflows using Visual Studio
    http://msdn.microsoft.com/en-us/library/office/jj163199(v=office.15).aspx
    How to: Create SharePoint 2013 Workflows using Visual Studio
    http://msdn.microsoft.com/en-us/library/office/dn584771(v=office.15).aspx
    Developing SharePoint 2013 workflows with Visual Studio demo
    http://www.bing.com/videos/watch/video/developing-sharepoint-2013-workflows-with-visual-studio-demo/10t0er5gh
    Best Regards
    Dennis Guo
    TechNet Community Support

  • Need Help in Splitting a String Using SQL QUERY

    Hi,
    I need help in splitting a string using a SQL Query:
    String IS:
    AFTER PAINT.ACOUSTICAL.1..9'' MEMBRAIN'I would like to seperate this string into multiple lines using the delimeter .(dot)
    Sample Output should look like:
    SNO       STRING
    1            AFTER PAINT
    2            ACOUSTICAL
    3            1
    4            
    5            9" MEMBRAIN
    {code}
    FYI i am using Oracle 9.2                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    There's this as well:
    with x as ( --generating sample data:
               select 'AFTER PAINT.ACOUSTICAL.1..9" MEMBRAIN' str from dual union all
               select 'BEFORE PAINT.ELECTRIC.2..45 caliber MEMBRAIN' str from dual)
    select str,
           row_number() over (partition by str order by rownum) s_no,
           cast(dbms_xmlgen.convert(t.column_value.extract('//text()').getstringval(),1) as varchar2(100)) res
    from x,
         table(xmlsequence(xmltype('<x><x>' || replace(str,'.','</x><x>') || '</x></x>').extract('//x/*'))) t;
    STR                                                S_NO RES                                                                                                
    AFTER PAINT.ACOUSTICAL.1..9" MEMBRAIN                 1 AFTER PAINT                                                                                        
    AFTER PAINT.ACOUSTICAL.1..9" MEMBRAIN                 2 ACOUSTICAL                                                                                         
    AFTER PAINT.ACOUSTICAL.1..9" MEMBRAIN                 3 1                                                                                                  
    AFTER PAINT.ACOUSTICAL.1..9" MEMBRAIN                 4                                                                                                    
    AFTER PAINT.ACOUSTICAL.1..9" MEMBRAIN                 5 9" MEMBRAIN                                                                                        
    BEFORE PAINT.ELECTRIC.2..45 caliber MEMBRAIN          1 BEFORE PAINT                                                                                       
    BEFORE PAINT.ELECTRIC.2..45 caliber MEMBRAIN          2 ELECTRIC                                                                                           
    BEFORE PAINT.ELECTRIC.2..45 caliber MEMBRAIN          3 2                                                                                                  
    BEFORE PAINT.ELECTRIC.2..45 caliber MEMBRAIN          4                                                                                                    
    BEFORE PAINT.ELECTRIC.2..45 caliber MEMBRAIN          5 45 caliber MEMBRAIN      
    {code}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • I wanted to send some photos out but was told I need to create a new profile, use mail icon in control panel no icon there how do I get it done?

    I want to send some photos from Firefox, when I tried it said I need to create a new profile, use mail icon in control panel. I went to control panel and do not know what to do.'''bold text'''

    As all of the msuic came from your computer in the first place it should still be there.  Is it not?
    EVERYTHING on your ipod should also be on your computer and should be included in your regular backup copy of your computer.
    Make sure that everything is on your computer.  You can transfer itunes purchases from the ipod.  Without syncing:  File>Transfer Purchases.
    When everything is on your computer, then it can be synced back to the ipod after updating.

  • I need help replacing a battery in my ipod nano 4th geneartion 16 gb can someone help me with step by step instructions or help me send it to apple store and replace and if so how?

    i need help replacing a battery in my ipod nano 4th geneartion 16 gb can someone help me with step by step instructions or help me send it to apple store and replace and if so how?

    Here is how to do it yourself.
    http://www.youtube.com/watch?v=2h53otOBTsI
    Here is how to send it to apple.
    http://www.apple.com/support/ipod/service/battery/
    Hope this helps!

  • I need help please , i try to use itunes but my iPhone don't appear on itunes, i try everyting ,dowwload itunes again restart computer and iPhone,restart running device support,etc.

    i need help please , i try to use itunes but my iPhone don't appear on itunes, i try everyting ,dowwload itunes again restart computer and iPhone,restart running device support,etc.

    Windows doesn't detect iPhone: http://support.apple.com/kb/ts1538
    Mac: http://support.apple.com/kb/ts1591

  • I need to create a iTunes account using my work email but...

    I need to create a iTunes account using my work email address but when I try it says that there is already an iTunes account linked to my work email - I have never done this so I know that I have not created this and therefore can't answer the security questions in order to check it out.  It also means I can't set up this iTunes account - any ideas?

    When Apple increased security on the accounts we were asked to create security questions and answers and to offer a rescue email address, could you have used the work address then?
    http://support.apple.com/kb/HT5312

  • I have a Steinberg MI4 and a Roland Fantom X7, and am trying to use my Fantom in Logic to record audio. Need help setting it all up using MIDI cables. Please help !

    I have a Steinberg MI4 and a Roland Fantom X7, and am trying to use my Fantom in Logic to record audio. Need help setting it all up using MIDI cables. Please help !

    Encryption wouldn't matter except for Wifi.
    While 10.2 might help, there's not much you can do on the Internet these days with less than 10.4.11
    Tiger Requirements...
    To use Mac OS X 10.4 Tiger, your Macintosh needs:
        * A PowerPC G3, G4, or G5 processor
        * Built-in FireWire
        * At least 256 MB of RAM (I recommend 1GB minimum)
        * DVD drive (DVD-ROM), Combo (CD-RW/DVD-ROM) or SuperDrive (DVD-R) for installation
        * At least 3 GB of free disk space; 4 GB if you install the XCode 2 Developer Tools  (I recommend 20GB minimum)
    http://support.apple.com/kb/HT1514
    http://www.ebay.com/sch/i.html?_nkw=mac+os+x+tiger+retail+10.4
    See Tom's, (Texas Mac Man), great info on where/how to find/get Tiger...
    https://discussions.apple.com/message/15305521#15305521
    Or Ali Brown's great info on where/how to find/get Tiger...
    http://discussions.apple.com/thread.jspa?messageID=10381710#10381710
    As far as Memory, that's sort of easy, find your eMac here...
    http://eshop.macsales.com/MyOWC/Models.cfm?Family=emac&sType=Memory
    As far as Hard Drive, it's not easy to replace the Internal drive, I'd maybe suggest an external Firewire drive to boot from...
    http://eshop.macsales.com/item/Other%20World%20Computing/MAU4S7500G16/

  • I need help linking Microsoft SDK to My visual studio 2010 sp1 project?

    I need help linking Microsoft SDK to My visual studio 2010 sp1 project?
    Hi, I'm on windows 8.1 and I'm getting a lot of Direct x sdk errors every time I try to debug or release a project. Please help me I'm lost trying to fix's this, thanks.

    Hi programmerblizz,
    According to your description, could you please tell me which kind of project you try to debug or release? Is it a c++ project or other?
    If it is a c++ project, I suggest you can refer the following thread check your issue in your side.
    Reference:
    http://stackoverflow.com/questions/26303922/directx-9-cannot-find-the-include-libaries
    If no, please tell me more detail message about your issue.
    Best Regards,
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Allan Eckert, need help on G5 Coolscan 5000 use

    Allan , need help on G5 Coolscan 5000 use. Please email me from my profile.
    Thank you,
    Frank

    Just to chime in with my 2 cents and experience ...
    A few years ago I used a coolscan 4000 to scan my personal slides as a project. I had about 2000 of them from over the last 20 years and it took me about 6 weeks of personal time to do this. It was done on a Windows P4 2.5GHz Dell, but the slowest part was the actual scanning itself. I used 1 pass, Digital ICE, and saved them as 16bit TIFFs .... a whopping 65MB per scan.... To speed things up I bought the Nikon Slide adapter ($600 CDN) that would batch scan 50 slides at a time, however it would jam ( especially with the older cardboard mounted Kodachrome slides) periodically ... oh maybe 20-30 times with 2000 slides, and that really wasted time as I had to determine what need to be rescanned, and restart at the offending slide. This also would happen in the middle of the night when I was sleeping after setting the batch scan to run all night. Jamming often occurred as two slides tried to be scanned at the same time, as well as a slightly 'bent or creased' mount I found that the newer plastic mounts were better, but not entirely jam free, Nikon has some info on how well the various mounts work in their adapter on their website. Anyway I wish you well with 300+K slides to scan and recommend the batch slide adapter, and I think your speed will be determined more by the HW scan time than the CPU/GPU, so I would try to get as many scanners going as you can with that number of slides.
    -Robert
    PS I now have all originals in Aperture, and gave up the Dell 3 years ago.

  • Can anyone help i want to call java class using visual basic

    I want to call java class using visual basic and send some arguments to the main class

    Hi,
    I don't know VB, but you can surely launch a command line like :
    javaw.exe mypackage.MyMainClass myArgument1
    Regards

  • How do I open a pdf stored in a Microsoft Access database using Visual Basic studios 2012

    Currently I am unable to find a valid method of being able to open a pdf stored in a Microsoft Access database using Visual Basic studios 2012. I've tried displaying the entire database on a form, but when I do this all the other columns show up with
    the correct data besides the one containing the pdf's, it just displays <binary data> in each row down the column. I also tried another method with which you use the database as a dataset and can drag and drop the rows and columns into the form, which
    again works for all the other columns besides the one containing the pdf's but this time I'm unable to interact with the column  at all. 
    Not too sure if this is in the correct place, but any answers or help would be appreciated. Cheers.

    Alex,
    This forum is dedicated to Project and Project Server. You might get better response, if you post to a Visual Basic forum. Here are couple I could find. 
    https://social.msdn.microsoft.com/Forums/vstudio/en-US/home?forum=vbgeneral%2Cvblanguage&filter=alltypes&sort=lastpostdesc
    Cheers,
    Prasanna Adavi, Project MVP
    Blog:
      Podcast:
       Twitter:   
    LinkedIn:
      

  • How to access Oracle Data Base on Unix using Visual Basic ?

    Hi !
    I want to use visual basic and access the Oracle Data Base on Unix server. How can i do that ? Do i need any software?
    .Prashant

    You need an oracle client installation and setup your TNS names.

Maybe you are looking for