Programs won't execute in batch files

Status
Not open for further replies.

Karmashock

Posts: 223   +0
Basically, if the command is part of the shell such as "echo" the batch file won't have a problem with it. But if you try to execute ANYTHING that isn't part of the shell such as chkdsk for example which is a program... you get nothing.

What's really weird is if you launch cmd manually and type something in it works perfectly. I'm guessing this is some kind of permissions issue but I am using an admin account. Anyone seen this before?
 
You can use the DOS "Start" command (in your batch file), ie:

Start chkdsk C: /r

To start CheckDisk (actually, it will ask you Yes or No, to start on next restart)

Edit:

Oh or "Call"

Call chkdsk C: /r
 
Sorry, did you try "Call" as stated above?
I walked away and then thought, oh wait, call should do it

Are you running this batch file inside Windows, or from a bootcd
 
no... no program outside of the shell will run in batch. I can execute them just fine manually by typing in the program name into the prompt. But in a batch file it tries to execute over and over again. IF you leave echo on you can see it trying to run the command over and over and over to no effect.

it doesn't matter what it is... ping... notepad... any program outside of the shell fails to execute in batch.
 
You need an "Exit" command, at the end


By the way, I just tested this on XP, creating Test.bat, and all of them worked. You try:
@echo off
Title: Notepad
echo.
echo Using CALL
call Notepad
pause
echo.
echo Using Start
Start Notepad
pause
echo.
echo using no command
Notepad
pause
echo.
exit
Save in Notepad > All files > Test.bat
 
Weird... ok, they all worked that time.

Several others are starting to work that were not working yesterday. The one that still won't run from batch is chkdsk.
 
I just tested CheckDisk, all 3 command, and it works
Try copying and pasting this one to Notepad
Maybe you had a spelling or syntax error?
@echo off
Title: CheckDisk
echo.
echo Using CALL
call chkdsk /r
pause
echo.
echo Using Start
Start chkdsk /r
pause
echo.
echo using no command
chkdsk /r
pause
echo.
exit
Oh, just answer N when prompted to run it
 
It says "using call" over and over and over again... it's moving so fast it's just a blur on the screen.

It should be noted that I know how to use batch files. The old batch script was unchanged from one I used for years before a recent reinstall. After the reinstall batch files have become unpredictable. Mostly what happens is that endless cycling to execute a command that never gets executed.

You can see it sitting there trying again and again to launch it.
 
I'm very good at batch files too ;) so these simple commands are annoying :D

Obviously you have an Exit command?
And I did put "pause" in there
I'm thinking that its "calling" another batch by the same name, ie chkdsk.bat, or something silly :confused:
 
No, it's not running through the whole batch file at warp speed. It's just running that ONE command that won't run over and over and over again.

For example, if I put Chkdsk /? on one line it wouldn't matter if I put exit on the next. It would never get there. IT would just cycle endlessly with "chkdsk /?". On another computer it displays the help text and then closes.


It's weird. I've checked the NTFS permissions of the file and it doesn't matter.
 
After the reinstall batch files have become unpredictable.
Reinstall... Exactly what is your understanding of this?
Mine is removing the partition and then installing Windows clean
Maybe there's some Malware on your computer?
Batch files usually don't care a lot on Windows issues (although CheckDisk may help)
 
Well... I reinstalled on a fresh partition... then after a few weeks I ghosted that partition onto a level 1 raid.

I don't know when the issue started so I don't know if the ghosting did it. I don't understand how this could even be a problem. What the hell is wrong here...


bah...
 
Oh, Ghost and Raid, not a good match
I have seen ghosted images cause strange issues myself (being a Ghost imager myself)
What was it again?.... Um, something about the bootloader or Partition requiring a repair (at the time I used Partition Magic to fix errors without hurting my file system, but PM is now old and basically probably won't work)
You could use a free live BootCd like Gparted BootCD, to check your partitions, but with Raid (number?) I'm not to sure if you "fix" any issue without upsetting the filesystem

Your thoughts?
 
Well, it's raid 1... that is a simple mirror array. Further, it's a full hardware raid. Drivers aren't even needed to make the raid work. The array just looks like a single scsi harddrive to dos.

Beyond that i've scanned the drive a few times with Chkdsk and it doesn't find anything besides the incidental security errors... the sort of thing checkdisk always finds.

Also, the OS is booting off of this partition without a problem. I'm really very happy with this system. It's just a few weird things.

1. Chkdsk won't run from a batch file.

2. DVD burn operations lock up the computer when they reach 6 percent (5 coasters and counting.) I have to reboot to get the system responsive again. I don't know if this happened before or after the ghost but it didn't happen before reinstall.

3. ATI Catalyst Control Center errors out whenever it's loaded. Drivers work just fine but not CCC. It's odd. I'm certain that this at least worked before the ghost operation.

There might be more... for example MSCONFIG required that I set certain settings a few times before they took. Everything kept reverting back as if I hadn't gone in and disabled certain start up items. But that might be the new firewall/antivirus. I'm using Avira Antivir which I'm new to... I typically use Comodo or AVG. I'm also using Outpost firewall for the first time. I don't know if either of those programs monitor start up items and nixed the change without telling me.
 
no... no program outside of the shell will run in batch. I can execute them just fine manually by typing in the program name into the prompt. But in a batch file it tries to execute over and over again. IF you leave echo on you can see it trying to run the command over and over and over to no effect<snip>
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?)
 
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?)

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.
 
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 :) )
 
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.
 
@echo off
Title: CheckDisk

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

chkdsk %scandrive% /f /v /x
pause
exit
Use "chkdsk.exe %scandrive% /f /v /x" to avoid the name conflict with chkdsk.bat
 
Status
Not open for further replies.
Back