need help with winrar cmd and batch

Discussion in 'Software' started by red death68, Apr 26, 2011.

  1. red death68

    red death68 Command Sergeant Major

    basicly i have been toying with a way to make sfx archives rebuild themselves after running with updated files and i found a solution using winrar cmd line through rar.exe but theres a problem i have run into once the batch is in the archive how do i make it realize where the archive that launched it is located so it can rebuild the archive with the new files?
     
  2. red death68

    red death68 Command Sergeant Major

    does anyone have any idea how on earth i could make the batch file find the sfx archive that launched it?

    perhaps a cariable or a registry value?

    maybe create a registry value of some sort i really have no idea and i wanna really really make this work so any ideas are welcome im willing to try just about anything right now

    (also other script forms are fine by me especialy if they lead toa output saved as a text doc)
     
  3. GermanOne

    GermanOne Guest

    Sorry, but I'm totally confused :confused
    You have to call rar.exe with the archive full name as argument. That means you have to know where the archive is placed on your drive before it is opened by rar.exe. I don't understand what else you're looking for.

    Regards
    GermanOne
     
  4. red death68

    red death68 Command Sergeant Major

    thats actually exactly my problem im trying to find where the sfx will be located when it launches because i need to use the winrar cmd line to rebuild that archive with the updated files everytime the game is closed (thanks to the start /wait cmd) but i have no way of knowing where its from the best i can find is the %0 veriable but thats no good because it only leads to the running batch file so this is basicly what i wanna do


    1.) you double click archive it extracts to a predefined location (%temp%\RarSFX1)
    2.) the game save data inside archive is copied to the appllication data folder where it is by default(only place i know of where the game will read it short of hacking the exe which is way to much trouble)
    3.) the game is started using the start /wait cmd
    4.) after closing it recopies the save data to %temp%\RarSFX1
    5.) the archive is then rebuilt by replacing the 2 new save data files using the rar cmd line tool
    6.) the game can then be run on another system with the save data intact

    my problem is step 5 because i need to know where the sfx archive is located that launched it i was thinking using the mru reg value but there a 2 problems first the name of the value is the path its located at and i cant find a way to query based on data instead of value name and second some people can disable their mru list by tweaking the registry

    so i need a way of locating the file short of creating a reg value using it then deleting it but i still have the problem of telling the batch what the path of the archive is. any idea's will be more then welcomed(also any script type is welcome too i can just write the contents to a txt doc and run the text results through cmd like with my uninstaller.
     
  5. GermanOne

    GermanOne Guest

    You cannot create a registry value by double clicking the .sfx archive. How should the archive know that it has to write to the registry?
    The easiest way would be that the .sfx file is always saved in a directory relative to your batch file. You will find the current folder of your batch file in %~dp0.

    Regards
    GermanOne
     
  6. red death68

    red death68 Command Sergeant Major

    no the value would be created by the batch file that is run when you double click the archive

    if there is a way to determine where the archive was located then i could just make it create a value based on that then read the value for the path. then delete it
     
  7. PC-XT

    PC-XT Master Sergeant

    I assume this thread is from http://forums.majorgeeks.com/showthread.php?p=1615419#poststop and that you have the archive set to extract itself to the temporary folder, then run the vbs file, which runs the batch file hidden. The only way for the batch file to know the location, besides asking the OS, would be for the archive to tell the vbs, which would then tell the batch file. I don't know if you can set up sfx archives to give their location to the program they launch after extraction...

    In short, you are attempting to make a self-modifying sfx archive that contains a game. I've heard of self-deleting sfx archives, but I don't think they were intended for self-modification. I think I would just hard code the intended location into the batch file, and change it if I moved it to another medium.

    I don't know how accurate the MRUs are. If you wanted to use them, you could attempt to get the location before running the game, so you could give a warning that it can't be saved before playing.
     
  8. red death68

    red death68 Command Sergeant Major

    yes thats the same thread i figured since no one in software had any idea id try programming see if there was a script solution i have heard of a 7z sfx archives having a veriable ability it said this int he variable section

    but no matter how i try i cant get my peramaters right and im more used to winrars sfx options
     
  9. red death68

    red death68 Command Sergeant Major

    sorry for double post but i found a partial solution by searching the hard drive using the cmd line

    dir "ab.exe" /s /od

    the only problem is if they rename the exe is there a way to prevent renaming of the file? or add some kind of message that renaming it will cause files to be saved no longer?
     
  10. GermanOne

    GermanOne Guest

    Well, it wastes your time if you search the entire drive for the archive. Further more: What happens if you found more than one file?

    Also the MUICache in your registry is not suitable. You have to determine the SID of the current user (S-1-5-21-2959977528-1968549182-1748389834-1008 in your case, S-1-5-21-833488969-754802100-427847919-1000 in my case) and the OS because the path is not the same (HKEY_USERS\S-1-5-21-2959977528-1968549182-1748389834-1008\Software\Microsoft\Windows\ShellNoRoam\MUICache in your case on XP, HKEY_USERS\S-1-5-21-833488969-754802100-427847919-1000_Classes\Local Settings\Software\Microsoft\Windows\Shell\MuiCache in my case on Win7 Starter). And latest you have the same problem if it is allowed that the user could rename the archive.

    In my opinion thats all too complicated. Do it like I suggested before. Each program will interrupt if a user renamed one of the needed files or moved it to another place. Would you ever rename a .dll or .exe file in the Program Files folder ...?

    Regards
    GermanOne
     
  11. red death68

    red death68 Command Sergeant Major

    no i wouldnt but im a tech geek and not one of the computer novices that i know may use my portable copy

    so if i understand your method i make the files all extract to the same directory as the archive? if so will it still run the exe from cmd if i have set the file to hidden?

    also can it use hidden files to rebuild the archive?
     
  12. GermanOne

    GermanOne Guest

    Ha ha, no the program files folder was only an example. I've got some portable apps (like Firefox or VLC) on my pen drive, finally it's the same. Somewhere on the drive is the root folder for the app. This contains only the main executable and maybe a readme.txt or a help.html. Further there are one or more sub folders with the needed files. You should never try to rename or move some of the files or sub folders. Everyone should be aware.


    It's up to you where you extract it. You could also create a sub directory in %temp% as you told before.


    Yes, why not.


    Yes I guess.


    To summarize:
    Place your HTA file to a folder and create a sub folder (maybe named Data) where you could save your batch files and the archive.
    Probably the only thing you have to determine is the current location of the HTA file. Have a look at this simplified code:
    Code:
    <html>
      <head>
        <HTA:Application>
        <title>Get Own Location</title>
        <script language="VBScript">
        Sub window_onLoad
          Set oFSO = CreateObject("Scripting.FileSystemObject")
          strHtaPath = oFSO.GetParentFolderName(location.pathName)
          Set oFSO = Nothing
    
          out.innerHtml = strHtaPath
        End Sub
        </script>
      </head>
      <body ID="out"></body>
    </html>
    
    Regards
    GermanOne
     
  13. red death68

    red death68 Command Sergeant Major

    thanks for the idea's now just to tweak some files and what not btw can you use the %cd% variable for things like copying and the start cmd?

    if so i dont know why im havving trouble and before you ask of course i put the variable in quotes
     
  14. GermanOne

    GermanOne Guest

    Hmm, normally it should work (but it isn't clear to me why you don't use relative pathes). If you try to use %cd% for the current batch directory you better should use %~dp0 because %cd% can be changed by CD, PUSHD and POPD.
    Maybe you could post the code or a part of it.
    BTW For testing you could prepend an ECHO command to display the values of the variables, eg.
    Code:
    ECHO copy "%cd%\somewhere\abc.txt"
    ECHO copy "%~dp0somewhere\abc.txt"
    PAUSE
    
    Regards
    GermanOne
     
  15. red death68

    red death68 Command Sergeant Major

    ill try you %~dp0 suggestion and get back to you later rightn now running a cpu intensive program
     
  16. GermanOne

    GermanOne Guest

    Er, you mean that you're playing a computer game :-D
    BTW Congratulations to your 700th post.

    Regards
    GermanOne
     
  17. red death68

    red death68 Command Sergeant Major

    lol naw hash cracker testing how vaslnurable my password is lol(needed something to do when i wasnt home)

    and ty i didnt notice it
     

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