views:

13

answers:

0

Hello,

I'm trying to set environment variables (via SET) through a bat file which then submits job to the scheduler. However it does not set it right the first time. I have to run the bat file twice to make it run correctly. Why is this happening?

Thanks!

@echo off

if exist b.inp ( echo b.inp exists set /a procs=0 for /f %%a in ('findstr /N "." b.inp ^| find /c ":"') do set /a procs=%%a set /a meshcount=procs - 1 ) else ( set INPFILE= IF NOT "%Extension%"=="" set INPFILE=a.%Extension% echo %Extension% extension IF "%Extension%"=="" set INPFILE=a.inp set /a meshcount=0 echo am i here? echo 123 %INPFILE% )

When I run the script first time I get this:

C:\Users\Administrator>batfile extension am i here? 123

When I run it again, I get what I expect:

C:\Users\Administrator>batfile extension am i here? 123 a.inp

related questions