Jump to content

cmd file close automatically when there is a "if"


oskingen

Recommended Posts

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 laptop
start /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.

Link to comment
Share on other sites


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 password
ECHO INSIDE IF BEFORE START&PAUSE
start /wait Settings\cmd\AddCredentials.cmd
ECHO INSIDE IF AFTER START&PAUSE
)
ECHO PAST IF&PAUSE

What output you get?

jaclaz

Edited by jaclaz
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...