MoonPoint Support Logo

 

Shop Amazon Warehouse Deals - Deep Discounts on Open-box and Used ProductsAmazon Warehouse Deals



Advanced Search
February
Sun Mon Tue Wed Thu Fri Sat
15
2009
Months
Feb


Sun, Feb 15, 2009 9:21 pm

BIOS Info Using VBScript

Microsoft has a webpage on Microsoft TechNet titled Retrieving Information About the BIOS, which provides details on how to retrieve information for the BIOS, such as a description and version number for the BIOS, using VBScript.

I created a script, bios-info.vbs from the code provided on Microsoft's webpage that will retrieve the information from the BIOS.

[/os/windows/utilities/sysmgmt] permanent link

Sun, Feb 15, 2009 8:42 pm

Toshiba M35X Laptop Powers Off Randomly

I've been having a lot of power problems with a Toshiba laptop, model number M35X-S109 and part number PSA7U-01300U, recently. The system will randomly power itself off without warning. Often, when I power it back on, the battery will show a very low charge and will be charging. At Satellite model M35X - fixing power connector, I found that this model of Toshiba laptop is known for having a power connector problem. The webpage has pictures of the power connector on the motherboard showing signs of the problem. Pictures are also shown illustrating a repaired power connector. Another webpage with information on the problem is Toshiba Satellite M35X and Satellite A75 power jack and battery charge problem. There is a Toshiba Satellite A75 failed power jack workaround page detailing how one person, who had his laptop repaired multiple times to fix the problem, finally resorted to moving the power connector outside the laptop case. Another reference to the problem is at Satellite 1900. Laptop loses power and shuts down without warning.

I have the Toshiba Power Management Utility configured on the system to sound an alarm and display a message when the battery charges drops to 10%. I have it configured to sound an alarm, display a message, and hibernate when the charge drops to 5%. But it never takes those actions. Instead, the laptop just powers off.

So that I could at least have some forwarning of when the battery charge is getting very low, I installed Laptop Battery Power Monitor, which places a battery widget on the desktop which displays the battery's charge level and which appears above other windows.

[/pc/hardware/toshiba] permanent link

Sun, Feb 15, 2009 8:37 pm

Laptop Battery Power Monitor 2006

Laptop Battery Power Monitor allows you to track the battery charge for your laptop's battery. A battery widget appears on your desktop when the program is installed, which can be dragged across your desktop and placed over any window. To make it less intrusive, you can adjust the transparency of the battery. In addition, the battery can be resized to 33%, 50%, or 75% of its original size. If you place your mouse over the battery, your battery's charge status, total hours remaining, and percentage of battery life remaining will be displayed.

When you run the downloaded file, setup.exe, by default, it will attempt to extract the files stored within itself to c:\Temp\BatteryMonitor2006. If there is no c:\Temp directory, you will receive the message below:

WinZip Self-Extractor

White X in red circleCould not create "c:\Temp\BatteryMonitor2006" - unzip operation cancelled.

OK

 

In that case, choose another directory into which the files will be extracted. The software requires 6,992 KB of free space on the disk on which it will be installed.

The installation process creates a program group named Duomart.com. Within it you will find a Laptop Battery Power Monitor group. When you run the progam it will place a battery widget on your desktop showing the battery charge level.

DuoMart battery charge widget

That widget will remain over top of windows that you open. Moving the mouse pointer over it will display information about the state of the battery. If you right-click on it, you can change the size of the battery displayed. You also have the option to adjust its transparency or close the program.

The software can be downloaded from the developer website, which is a source for purchasing computer accessories, bluetooth devices, or laptop batteries. Other sources for the software are listed below.

Download Sites

DuoMart
MoonPoint Support
FileBuzz

[/os/windows/utilities/sysmgmt] permanent link

Sun, Feb 15, 2009 3:46 pm

Substring Extraction with the FOR /F Command

I want to obtain the file name listed as the value for Wallpaper in the registry key HKCU\Software\Microsoft\Windows\CurrentVersion\Themes\LastTheme. I can do so using the reg query command.
C:\>reg query HKCU\Software\Microsoft\Windows\CurrentVersion\Themes\LastTheme /v
 Wallpaper

! REG.EXE VERSION 3.0

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Themes\LastTheme
    Wallpaper   REG_EXPAND_SZ   %SystemRoot%\Web\Wallpaper\Ripple.jpg

From a batch file, though, I only want the filename, i.e. %SystemRoot%\Web\Wallpaper\Ripple.jpg.

I can select just that part of the output usng the FOR /F command in a batch file. The syntax of the FOR /F command is as follows:

FOR /F ["options"] %%parameter IN ('command_to_process') DO command

Key
   options:
      delims=xxx   The delimiter character(s)
                   (default = a space)
      skip=n       A number of lines to skip at the beginning. 
                   (default = 0)
      eol=;        Character at the start of each line to indicate a comment
                   The default is a semicolon ;  Use "eol=" to process all lines 
      tokens=n     Specifies which numbered items to 
                   read from each line 
                         (default = 1)

      usebackq     Specify `back quotes`
                      the command_to_process is placed in `BACK quotes`
                      instead of 'straight' quotes

   command_to_process : The output of the 'command_to_process' is 
                        passed into the FOR parameter.

   command     : The command to carry out, including any 
                 command-line parameters.

   %%parameter : A replaceable parameter:
                 in a batch file use %%G (on the command line %G)

FOR /F processing of a command consists of reading the output from the command one line at a time and then breaking the line up into individual items of data or 'tokens'. The DO command is then executed with the parameter(s) set to the token(s) found.

By default, /F breaks up the command output at each blank space, and any blank lines are skipped. You can override this default parsing behavior by specifying the "options" parameter. The options must be contained within double quotes.

In this case, the last line of output is the following:

    Wallpaper   REG_EXPAND_SZ   %SystemRoot%\Web\Wallpaper\Ripple.jpg

The delimiter between the fields in the output is the tab character (I checked for whether the delimiter was spaces or tabs with hod by redirecting the output of the reg query command to a file with reg query HKCU\Software\Microsoft\Windows\CurrentVersion\Themes\LastTheme /v Wallpaper > temp.txt). For the FOR /F command, the default delimiter is the space and tab characters so I don't have to specify delims=. But, if I don't, the output will be incorrect in cases where the path name or file name contain spaces, since the second space will be treated as a demarcation point, so that the space-separated parts of the path name or file name are treated as separate tokens.

"Tokens" are the parts of the line separated by the delimiter. In this case, I'm only interested in the third token, i.e. %SystemRoot%\Web\Wallpaper\Ripple.jpg, so I can use the following lines in a batch file:

FOR /F "tokens=3" %%R in ('reg query HKCU\Software\Microsoft\Windows\CurrentVersion\Themes\LastTheme /v Wallpaper') DO SET wallpaper=%%R
echo %wallpaper%

I used the tokens=3 option to select just the third token on the output line. The %%R for the parameter name is arbitrary. I could have called it %%S, %%T, etc., instead, if I wished. The command I wished to process is enclosed between '( and )'. Note: for the reg query command, if the registry key contains spaces in the key name, then you must enclose the registry key name within double quotes as in the following batch file example:

@echo off FOR /F "tokens=3" %%R in ('reg query "HKCU\Control Panel\Desktop" /v ConvertedWallpaper') DO SET wallpaper_file=%%R
echo %wallpaper_file%

The output produced by the batch file is shown below:

C:\WINDOWS\Web\Wallpaper\Ripple.jpg

But, if I checked the value for OriginalWallper in the registry key HKCU\Control Panel\Desktop with reg query as below, I would see a path name containing spaces.

C:\>reg query "HKCU\Control Panel\Desktop" /v OriginalWallpaper

! REG.EXE VERSION 3.0

HKEY_CURRENT_USER\Control Panel\Desktop
    OriginalWallpaper   REG_SZ  C:\Documents and Settings\James\Local Settings\A
pplication Data\Microsoft\Wallpaper1.bmp

If I don't specify delims= in the batch file, e.g., if I use the code below, I would get incorrect output.

@echo off FOR /F "tokens=3" %%R in ('reg query "HKCU\Control Panel\Desktop" /v OriginalWallpaper') DO SET wallpaper_file=%%R echo %wallpaper_file%

The output would be as shown below:

C:\Documents

That is because C:\Documents will be treated as one token and then the space between Documents and and Settings is treated as the demarcation point between two tokens. But, if I instead include delims= and immediately hit the tab key, that problem won't occur, since the the horizontal tab character between the fields will be used to break up the line into tokens.

@echo off FOR /F "delims= tokens=3" %%R in ('reg query "HKCU\Control Panel\Desktop" /v OriginalWallpaper') DO SET wallpaper_file=%%R echo %wallpaper_file%

You can't see any character after the delims=, but in order for the FOR /F command to work in this case, I had to type delims= and then hit the tab key while editing the file in Windows Notepad. If you then save the file, it will produce the correct output, e.g.:

C:\Documents and Settings\James\Local Settings\Application Data\Microsoft\Wallpaper1.bmp

Note: if you are using Vim as your editor on a Windows system, as I usually do, then you need to insert the tab character after delims= by hitting the Ctrl-I keys simultaneously. You can then hit the spacebar and type tokens=. If you just hit the tab key, your output won't be as you expect.

Wallpaper-info.bat is an example batch file to query the values in the Windows registry pertaining to the file used for the Windows wallpaper using the FOR /F command.

References:

  1. For - Loop through command output
    SS64.com
  2. NT's FOR /F command: tokens and delims
    Rob van der Woude's Scripting Pages

[/os/windows/commands] permanent link

Sun, Feb 15, 2009 11:42 am

Hod - Octal and Hexadecimal Dump Program for Windows

Hex and Octal dumper (hod) is a small (36,864 bytes for version 1.6) program, written by Muhammad A Muquit, that can display the contents of a file in hexadecimal and octal. It is available for Linux/Unix, Microsoft Windows, and SimpleTech SimpleShare NAS systems. For the Microsoft Windows version, simply extract hod.exe from the zip file available on the author's website.

If you just type hod file the contents of file will be displayed in both hexadecimal and ASCII.

C:\>"C:\Program Files\Utilities\hod.exe" temp.txt
          0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f   0123456789abcdef
       0: 0d 0a 21 20 52 45 47 2e 45 58 45 20 56 45 52 53  ..! REG.EXE VERS
      10: 49 4f 4e 20 33 2e 30 0d 0a 0d 0a 48 4b 45 59 5f  ION 3.0....HKEY_
      20: 43 55 52 52 45 4e 54 5f 55 53 45 52 5c 53 6f 66  CURRENT_USER\Sof
      30: 74 77 61 72 65 5c 4d 69 63 72 6f 73 6f 66 74 5c  tware\Microsoft\
      40: 57 69 6e 64 6f 77 73 5c 43 75 72 72 65 6e 74 56  Windows\CurrentV
      50: 65 72 73 69 6f 6e 5c 54 68 65 6d 65 73 5c 4c 61  ersion\Themes\La
      60: 73 74 54 68 65 6d 65 0d 0a 20 20 20 20 57 61 6c  stTheme..    Wal
      70: 6c 70 61 70 65 72 09 52 45 47 5f 45 58 50 41 4e  lpaper.REG_EXPAN
      80: 44 5f 53 5a 09 25 53 79 73 74 65 6d 52 6f 6f 74  D_SZ.%SystemRoot
      90: 25 5c 57 65 62 5c 57 61 6c 6c 70 61 70 65 72 5c  %\Web\Wallpaper\
      a0: 52 69 70 70 6c 65 2e 6a 70 67 0d 0a 0d 0a        Ripple.jpg....

For help on using the program, use the -h option.

C:\>"C:\Program Files\Utilities\hod.exe" -h
usage: C:\Program Files\Utilities\File\Analysis\hod.exe [options] <filename>
Where the options are:
 -v      : show version information
 -h      : show this help
 -o      : dump in octal
 -8      : show as block of 8 bytes
 -x str  : convert a hex input to decimal
 -d      : show offsets in decimal
 -s      : show identical output lines
 -r      : reverse hod hexdump to binary
 -w      : reverse regular hex bytes to binary

If no filename specified, it will read from stdin

Example:
$ hod file
$ hod < file
$ cat file | hod
$ cat file | hod -
$ hod < file
$ hod -o file
$ echo "hello" | hod
$ echo -n "hello" | hod
$ hod -x 1c0
1c0 : 448
$ echo "0a 01 ff ef 0b" | hod -w > bin.bin
$ hod bin.bin | hod -r > bin_again.bin

Note: -r and -w works with hexadecimal only.

If you want to convert an ASCII string, such as the word hello, to its hexadecimal equivalent, you can use the echo command to pipe the word to hod, as below.

C:\>echo hello | "C:\Program Files\Utilities\hod.exe"
          0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f   0123456789abcdef
       0: 68 65 6c 6c 6f 20 0a                             hello .

From the above output, you can see that the letters in hello have the following hexadecimal equivalent representation.

ASCIIHexNote
h68 
e65 
l6c 
l6c 
o6f 
SP20space
LF0aline feed

A space (hex 20) is listed after hello, since there was a space between the word and the | pipe operator that feeds the output of the echo command to hod. If I had placed the | immediately after hello, i.e. echo hello|, it wouldn't have been listed. A line feed (hex 0a) is shown after the space.

Download hod

Author's website

[/software/utilities] permanent link

Valid HTML 4.01 Transitional

Privacy Policy   Contact

Blosxom logo