also @ TechSpot: Exploit allows command prompt to launch at Windows 7 login screen

TechSpot

Programs won't execute in batch files

Discussion in 'Software Apps' started by Karmashock, Nov 23, 2009.

Thread Status:
Not open for further replies.
  1. LookinAround TechSpot Chancellor

    Not sure how much i might be able to add to the thread.. but in reading the thread i found a very curious point. Could you please verify your statement above

    As
    > If the commands were simply failing i'd expect the batch file to simply exit with nothing happening
    > But are you saying the batch file doesn't exit but keeps repeating a command (and i guess you then exit using Ctl-C?)
  2. Karmashock Newcomer, in training

    Yeah, that's exactly what happens. Though I just close the window when I'm done with it. It mostly seems to have a hard time with chkdsk. What I don't get is that it never used to have this problem in the past. I'm literally running an old batch file that I've used on the system successfully for years. Then one day it just went berserk... I've never been able to run chkdsk from a batch file on this computer since. Kinda sad.
  3. jobeard TechSpot Ambassador

    just use an absolute path to the program.

    you may notice that Echo %PATH% may have a few directories,
    but when the program you need is not in one of those shown,
    it will not work w/o the absolute path

    (eg C:\Program Files\Internet Explorer is not in the path) so to run it in a BAT file
    one would need C:\Program Files\Internet Explorer\Iexplored.exe (but that's an obsene example :) )
  4. Karmashock Newcomer, in training

    I figured it out. There was a mistake in the script... I don't know how it got in there but apparently something got changed in it.

    In addition, the name of the script was "chkdsk" so it was also executing itself somehow instead of the check disk program. What's especially odd about that is that the first thing the program does is prompt for the drive to be scanned. That didn't happen when it called itself. It just tried to run itself repeatedly without actually doing anything... even the part of the code that worked.


    The whole thing is pretty weird. I think some of it might have been due to the old system install. I had a version of XP that hadn't been reinstalled in about a year. It seems I always need to refresh everything at some interval or the system gets bogged down.


    Anyway, I had kinda given up on it and gave it a second look just today.


    If you're curious, this was the script:

    @echo off
    Title: CheckDisk

    ECHO What drive to scan?
    SET /p scandrive=
    SET scandrive=%scandrive%:

    chkdsk %scandrive% /f /v /x
    pause
    exit


    It looked like this when it was broken

    @echo off
    Title: CheckDisk
    ECHO What drive to scan?
    SET /p scandrive=
    chkdsk %scandrive%: /f /v /x
    pause
    exit


    I'm not sure why that doesn't work, but it doesn't. Adding the extra line and changing the name of the script to something besides chkdsk fixed the problem.
  5. jobeard TechSpot Ambassador

    Use "chkdsk.exe %scandrive% /f /v /x" to avoid the name conflict with chkdsk.bat
  6. Karmashock Newcomer, in training

    I would but it was just as easy to rename the file "CheckDisk"... *shrugs* :)
  7. jobeard TechSpot Ambassador

    that works too; just thought you would like to know of the name conflict and how to resolve it in the future :)
Thread Status:
Not open for further replies.