August 28, 200818 yr Hi, I got a problem on vista and server 2008. I made some .cmd file and everytime it reach an instruction with a if, the cmd.exe close automatically. here is an sample of my file@echo ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::@echo Power Configuration for your laptopstart /wait Settings\cmd\PowerOptions.cmd@echo ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::if "%COMPUTERNAME%" neq "ME" ( echo Adding your Credentials informations in storage of network password start /wait Settings\cmd\AddCredentials.cmd)As soon as it go down the "if "%COMPUTERNAME%.... it closes.How to solve this and is there any workaround ?If i tape this instruction manually it works fine but looks like if I use a bat file it doesn't work.
August 28, 200818 yr Have you enabled command extensions? I have no idea about this, but i think they need to be enabled for IF to work properly? This is just a guess.I do however think you need to include the ELSE command, or ELSE it will fail anyway ?!
August 28, 200818 yr No need to enable extensions, if you use instead of neq IF NOT no need for ELSE, at least not in the snippet code posted.Try editing as below:if NOT "%COMPUTERNAME%"=="ME" (ECHO INSIDE IF&PAUSE echo Adding your Credentials informations in storage of network passwordECHO INSIDE IF BEFORE START&PAUSE start /wait Settings\cmd\AddCredentials.cmdECHO INSIDE IF AFTER START&PAUSE)ECHO PAST IF&PAUSEWhat output you get?jaclaz Edited August 28, 200818 yr by jaclaz
Create an account or sign in to comment