son of a batch...

Discussion in 'Software' started by virtualchaos, Jul 26, 2004.

  1. virtualchaos

    virtualchaos Private E-2

    I'm trying to make a batch file that does the following:
    - Reads a registry string value
    - Compares that value to the value I want it to be
    - If it isn't the right value, then run an exe (which i can do)

    The problem is reading and comparing the registry value... this is what I have so far:

    @echo on

    :: set the current version number
    set currentVersion=8.0
    echo Current version is %currentVersion%...

    :: check for the registry key value
    :: returns in the form "REG_SZ 8.0" without the quotation marks
    reg -ListValue

    "machine\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{3E445912-91F7-4BBB-8F0C-90F812A3EB63}\DisplayVersion"

    :: compare the results with supposed results
    rem ahhhhhhhhh! can't figure it out

    :: if its good goto GOOD if bad goto BAD

    :END

    If anybody needs clarification LMK, and thanks!
     
  2. NeoNemesis

    NeoNemesis Moutharrhea

    What isn't working, it looks like you have it right there.
     
  3. snakefoot

    snakefoot Sergeant Major

    You could export the values to a temporary file and then use filecompare fc to see if there is a difference. Then use errorlevel set by the filecompare to determine whether they were equal or not.
     
  4. virtualchaos

    virtualchaos Private E-2

    i used an idea similar to yours, snakefoot... instead i did a find, which also sets the errorlevel to 1 or 0... now onto the next issue! lol

    i need another batch file to erase a hard drive using a utility called Gdisk (symantec)... its basically just got some good command line switches. This is what i was thinking.

    - Delete NTLDR, preventing WinXP from booting normally
    - In its place, figure out how to get the BIOS to boot to the NTFS drive (into DOS?), only to load gdisk into ram

    [edit] to clarify, after i figure out how to boot the NTFS drive and place whatever files are necessary on the drive, then i must reboot before loading gdisk into ram (or else it will be lost, duh.)

    - Once the program is in ram switch the drive over and run gdisk to erase the NTFS drive

    Will this work? is there an alternate solution? will our hero triumph over the evils of NTFS?
     
  5. goldfish

    goldfish Lt. Sushi.DC

    Do you know VB? WMI really does rock you know ;)
     
  6. virtualchaos

    virtualchaos Private E-2

    ive been using vb scripts in the batch files and executing using cscript... i used to know qbasic if that counts lol... other than that ive just been executing simple vbscript commands

    P.S. whats WMI?
     
  7. goldfish

    goldfish Lt. Sushi.DC

    http://forums.majorgeeks.com/showthread.php?t=38367

    Windows Management Insturmentation. You can use the FileSystem scripting object to manipulate files, and you can use the registry class to interact with the registry, and even better you can use REAL conditional statements, just like you would in VBScript!
     
    Last edited: Jul 28, 2004
  8. goldfish

    goldfish Lt. Sushi.DC

    Use the StdRegProv class... to get the value of that key... then compare it...
    Code:
    const HKEY_LOCAL_MACHINE = &H80000002
    strComputer = "."
    Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &_
        strComputer & "\root\default:StdRegProv")
    oReg.GetStringValue HKEY_LOCAL_MACHINE,"SOFTWARE","Microsoft","Windows\CurrentVersion\Uninstall\{3E445912-91F7-4BBB-8F0C-90F812A3EB63}","DisplayVersion",strValue
    if strValue = "somthing" then
    WScript.Echo "it equals somthing"
    else
    Wscript.Echo "it doesnt equal somthing"
    end if
    
    But, you've done it already ;)
     
  9. virtualchaos

    virtualchaos Private E-2

    Lol thanks for the vbscript after *rollseyes* but seriously, thanks for your input and good to know about WMI... never heard that acronym before. Any ideas about the gdisking thingamabob? Gdisk is a 16 bit app btw and i run it through a command line batch file. See today's message at 14:43 for details. Thanks again, guys, for your input.
     
  10. goldfish

    goldfish Lt. Sushi.DC

    Hum.

    I think you may want to use a bootdisk for this, try www.bootdisk.com and see if you can write a batch file (cant use WMI here!) which will load up ramdisk, copy the utility there, run it from there and do what you want it to.
     

MajorGeeks.Com Menu

Downloads All In One Tweaks \ Android \ Anti-Malware \ Anti-Virus \ Appearance \ Backup \ Browsers \ CD\DVD\Blu-Ray \ Covert Ops \ Drive Utilities \ Drivers \ Graphics \ Internet Tools \ Multimedia \ Networking \ Office Tools \ PC Games \ System Tools \ Mac/Apple/Ipad Downloads

Other News: Top Downloads \ News (Tech) \ Off Base (Other Websites News) \ Way Off Base (Offbeat Stories and Pics)

Social: Facebook \ YouTube \ Twitter \ Tumblr \ Pintrest \ RSS Feeds