Computing.Net > Forums > Programming > Strange problem in batch

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Strange problem in batch

Reply to Message Icon

Name: pball
Date: September 17, 2008 at 13:10:46 Pacific
OS: xp
CPU/Ram: 2 ghz 1 gig
Product: HP
Comment:

I have written a batch script to open drawings. The drawings have a formatted name. The following is how they can be named (x's are places for numbers)

UAxxxxxx
UAxxxxxx SH1
UAxxxxxx SH2
Uxxxxxx
Uxxxxxx SH1
Uxxxxxx SH2

some times there may a -x on the end of the numbers but that doesn't mess with the script.

Now for the problem, I have a variable which I set to a image viewing program. Then I try to start that program with a picture for it to open. Well if I use the start %prog% (pic name) the picture will open up in my default image viewer, but if i remove the start it will open in what ever program i tell it. The reason I want the start is so it doesn't pause the script while the image program is open. I will paste my script and if you have more specific questions please ask. I am just perplexed as to why this is happening.

@echo off

set prog=C:\Program Files\IGC\Brava! Reader\BravaReader.exe
set dp=G:\Active
set err=does not exist or uses non-standard name
set sht=1

echo Enter uaxxxxxx for UA drawings
echo Enter xxxxxx for U drawings
echo Type exit to exit program
echo.
:start

set /p dw=

if %dw% == exit goto exit

set U=U
if %dw:~0,1% == u set U=%null%

if exist "%dp%\%U%%dw%.TIF" (
start "%prog%" "%dp%\U%dw%.TIF"
goto end
)
if exist "%dp%\%U%%dw% SH1.TIF" (
goto sel
:return
if %sht% == 1 start "%prog%" "%dp%\%U%%dw% SH1.TIF"
if %sht% == 2 start "%prog%" "%dp%\%U%%dw% SH2.TIF"
if %sht% == 3 start "%prog%" "%dp%\%U%%dw% SH1.TIF" | start "%prog%" "%dp%\%U%%dw% SH2.TIF"
goto end
)
echo %err%

:end
echo.
goto start

:sel
echo 1 for sheet 1
echo 2 for sheet 2
echo 3 for both sheets
echo.
set /p sht=
goto return

:exit

Also note I have tried typing the names of the program and a picture behind it in the command prompt and that opens the picture in that program. It just doesn't work with start in front of it in my script



Sponsored Link
Ads by Google

Response Number 1
Name: Judago
Date: September 17, 2008 at 13:59:38 Pacific
Reply:

Try:


start "" "%prog%" "%dp%\U%dw%.TIF"

Start assumes that the first argument in "double quotes" should be the title of the new window. Specifying "" as the first argument gets around this. It would be nice if the help page in xp mentioned this.......


0

Response Number 2
Name: pball
Date: September 17, 2008 at 15:32:06 Pacific
Reply:

wow so simple

thanks I'll test it later


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Strange problem in batch

Special characters in batch www.computing.net/answers/programming/special-characters-in-batch/19558.html

path problem in batch file... www.computing.net/answers/programming/path-problem-in-batch-file/9916.html

Nesting variables in batch files ? www.computing.net/answers/programming/nesting-variables-in-batch-files-/14334.html