Winmount: Need Help W/ Batch File!

Discussion in 'Software' started by HarryPotter, Sep 16, 2026 at 8:22 AM.

  1. HarryPotter

    HarryPotter MajorGeek

    Hi! I have WinMount on two computers, but on one, it doesn't work properly: I can't mount an archive file. :( So, I'm using a batch file to decompress a file, use SUBST to mount the folder as a drive, wait until I'm done then recompress if necessary and clean up. The batch file follows:
    Code:
    @echo off
    ::echo %1
    echo Mounting your WinMount drive now...
    ::Change the path in the next line to the one of your WinMount installation:
    md "C:\MyPrgs\WinMount"
    md "C:\MyPrgs\WinMount\%~n1"
    "C:\Program Files\WinMount\WinMount.exe" -E %1 "-o:C:\MyPrgs\WinMount\%~n1"
    subst z: "C:\MyPrgs\WinMount\%~n1"
    pause
    subst /d z:
    choice /m "Save modifications to WinMount archive?"
    if errorlevel 2 goto exit
    "C:\Program Files\WinMount\WinMount.exe" -C "C:\MyPrgs\WinMount\%~n1" "-o:%~1"
    :exit
    rd /s /q "C:\MyPrgs\WinMount\%~n1"
    pause
    
    The problem is that, when I use it, I get an extra folder in the path, meaning the path contains an extra entry of the same name. What am I doing wrong? Is there a way to get WinMount to work properly, so I don't need this file? BTW, how do I run Explorer from a batch file?
     
  2. xrobwx71

    xrobwx71 Private First Class


    md "C:\MyPrgs\WinMount" remove this line
    md "C:\MyPrgs\WinMount\%~n1"

    explorer
    or a specific directory
    explorer "C:\Users\YourName\Documents"
     
  3. HarryPotter

    HarryPotter MajorGeek

    I don't understand why I have to remove the first md or how it would work. Thank you for the tip about Explorer, though. :)
     
  4. HarryPotter

    HarryPotter MajorGeek

    I'd prefer to mount using WinMount rather than extracting the contents of archive files and redirecting the folder to another drive. Any troubleshooting tips?
     
  5. xrobwx71

    xrobwx71 Private First Class

    Wouldn't having it twice make 2 directories?
     
  6. HarryPotter

    HarryPotter MajorGeek

    Maybe WinMount is recompressing the folder created by the batch file instead of its contents. But when I added "\*.*" to the recompression line, WinMount gives me an error. The help didn't help either. :(
     
  7. XoXgaming

    XoXgaming Sergeant

    md "C:\MyPrgs\WinMount"
    md "C:\MyPrgs\WinMount\%~n1"

    Yes

    Xrobwx71

    Is correct The second line deliberately creates a folder named after the archive. Then this line mounts the archive into that folder:

    If WinMount itself creates the mounted contents as a folder, that can result in the unwanted extra directory.

    If your goal is to have the archive's contents appear directly as Z:\, without the extra archive-named folder, the script should be adjusted so the temporary mount directory isn't nested under %~n1.

    I can rewrite the whole batch file to do exactly that while preserving the save modifications prompt.

    Try this
    @echo off
    echo Mounting your WinMount drive now...

    :: Temporary WinMount directory
    md "C:\MyPrgs\WinMount" 2>nul

    :: Mount archive
    "C:\Program Files\WinMount\WinMount.exe" -E "%~1" "-o:C:\MyPrgs\WinMount"

    :: Map the mounted directory to Z:
    subst z: "C:\MyPrgs\WinMount"

    pause

    :: Unmap Z:
    subst /d z:

    :: Ask whether to save modifications
    choice /m "Save modifications to WinMount archive?"
    if errorlevel 2 goto exit

    :: Save modifications back to the original archive
    "C:\Program Files\WinMount\WinMount.exe" -C "C:\MyPrgs\WinMount" "-o:%~1"

    :exit
    rd /s /q "C:\MyPrgs\WinMount" 2>nul
    pause

    The important change
    The original creates:

    C:\MyPrgs\WinMount\
    └── MyArchive\
    └── contents...

    The revised version mounts directly into:

    C:\MyPrgs\WinMount\
    └── contents...

    So when you access Z:, you should get:

    Z:\
    ├── file1
    ├── file2
    ├── folder1
    └── ...

    rather than:

    Z:\
    └── MyArchive\
    ├── file1
    └── ...

    I also changed %1 to "%~1" so an archive path containing spaces is handled correctly.


     
  8. HarryPotter

    HarryPotter MajorGeek

    Thank you. I plan to try your suggestions today. I'd really like WinMount to work properly, though.
     
  9. HarryPotter

    HarryPotter MajorGeek

    I prefer to decompress the archive file to its own folder but not add the extra folder to the path when recompressing the archive file. BTW, I usually don't use ">nul" as I like the information. :)
     

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