Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Batch help needed

  • 11-10-2009 6:45pm
    #1
    Registered Users, Registered Users 2 Posts: 8,423 ✭✭✭


    I have a batch file that runs perfectly on XP but not on Vista.

    The code is part of the batch file that scans the computer & returns a list of all available drives on the system, it then prompts the user to select a drive.

    Can anyone tell me from the details below, why this is not working on Vista?


    This is what gets returned when run under XP

    boardsxp.jpg


    This is what gets returned when run under Vista (UAC turned off)

    boardvista.jpg


    I would really appreciate if anyone can help me figure this out & get it to work on both XP & Vista :(

    @echo off
    set cnt=
    set errmsg=echo invalid number - select again^&^&goto select
    setlocal enabledelayedexpansion
    for /f "delims=" %%d in ('fsutil fsinfo drives^|find ":"') do (
    set tmp=%%d&&set tmp=!tmp:\=!&&set tmp=!tmp:Drives: =!
    for /f "delims=" %%e in ('fsutil fsinfo drivetype !tmp!') do (
    set /a cnt+=1&&echo !cnt! = %%e&&set ___var___!cnt!=%%e
    )
    )
    
    
    :select
    set drive=&&set err=&&set test=
    echo.
    echo.
    echo.
    set /p drive=please select your drive? 
    if not defined drive goto select
    if "%drive:~0,1%"=="0" %errmsg%
    for /f %%b in ('set /a %drive%*2 2^>^&1 1^>nul') do set err=%%b
    if defined err %errmsg%
    if %drive% gtr %cnt% %errmsg%
    set /a test=%drive%*2>nul
    if %test%==0 %errmsg%
    set str=!___var___%drive%!
    for /f %%c in ("%str%") do set drive=%%c
    set cnt=&&set err=&&set test=&&set errmsg=
    for /l %%g in (1,1,%cnt%) do set var%%g=
    setlocal disabledelayedexpansion
    
    echo.
    echo.
    echo.
    echo the drive you selected is %drive%
    
    echo.
    echo.
    echo.
    pause
    


    -

    "Everybody is a genius. But if you judge a fish by its ability to climb a tree, it will live its whole life believing that it is stupid."



Comments

  • Closed Accounts Posts: 2,980 ✭✭✭Kevster


    Yikes, I hate it when this type of incompatibility problem occurs. I do know that Vista signified an even further advance away from an MSDOS-based system than even WinXP though, and that could mean that some functions in the MSDOS shell were discarded in Vista. That could be what's happening here.

    This is an extreme longshot, but try to run the batch-file in the DOS-Box program on both XP and Vista, and you should get the same result each time. Alternatively - and this is an even greater longshot - run both in command.com and not cmd.exe

    Kevin


Advertisement