Gwcmd causes batch file to exit after restoring gateway backup

I am writing a batch file to set up a few things on a new Ignition Gateway PC. The first thing it does is to restore a gateway backup. Following that, I want it to do things like open ports in the firewall and so on.

However, as soon as the gwcmd command executes (successfully), the batch file exits.

Relevant code:

@echo off
set dirpath=%~dp0
cd "C:/Program Files/Inductive Automation/Ignition"
echo Restoring gateway backup...
set /p gwname="Please enter a name for the Gateway: "
gwcmd --restore "%dirpath%\IgnitionGateway.gwbk" --name %gwname% --promptyes
echo do other things...

The gwcmd command is successful - the gateway backup is restored with the specified name, and it restarts and is otherwise functional. However, as soon as the restore is complete, it very briefly flashes a message about being successful and closes the batch file. With the next line of the batch file being pause, I’m confident that it’s not code further down causing the issue.

Is this normal behaviour? Is there any way to fix it?

Edit: The batch file is being run as an administrator.

Yes, due to the way gwcmd is called.

Also yes. :slight_smile: Use a call function.

Thanks Jordan. So the best approach is to put my gwcmd snippets in their own batch file and call them from my master setup batch file. That I can do.

Is there any way to have the gwcmd batch file return a result to the master setup batch file, so that I know whether or not it succeeded?

You should be able to look at the ERRORLEVEL

ss64 is probably where I should have sent you the first time. :wink:


Thanks. Assuming that as usual, error code 0 = success, anything else = problems?

One final question - is it possible to do an online license activation with the utility? I see that there’s an option for creating an offline activation file, but it doesn’t appear that there’s any other license-related commands.