Published on InterSystems Developer Community (https://community.intersystems.com)

Home > freeze & thaw scripts on windows - a 'gotcha'!

Article
Stephen De Gabrielle · Nov 8, 2019 1m read

freeze & thaw scripts on windows - a 'gotcha'!

Hi, 

It turns out that on windows if you run a command with a windows command file you need to escape the % character as %%

In my case I could test freeze and thaw calls at the command line successfully as

..\bin\cache -s. -U%SYS ##Class(Backup.General).ExternalFreeze()

...but when my freeze script ran it would fail.

it turns out that a single '%' is striped when run in a windows command file, and it must be escaped as '%%' windows gets:

..\bin\cache -s. -USYS ##Class(Backup.General).ExternalFreeze()

So make sure your freeze and thaw scripts and include a double %%; 

..\bin\cache -s. -U%%SYS ##Class(Backup.General).ExternalFreeze()
 

I hope this helps

 

Stephen

 

PS In the case of the documentation it is worth noting that the thaw command wont run because it lacks the double %% :

https://cedocs.intersystems.com/latest/csp/documatic/%25CSP.Documatic.cls?PAGE=CLASS&LIBRARY=%25SYS&CLASSNAME=Backup.General#ExternalFreeze

 

'freeze.cmd' (with correct escaping)

..\bin\cache -s. -U%%SYS ##Class(Backup.General).ExternalFreeze()
rem note that we need to check errorlevel from highest to lowest here....
if errorlevel 5 goto OK
if errorlevel 3 goto FAIL
echo errorlevel returned wrong value
goto END
:OK
echo SYSTEM IS FROZEN
goto END
:FAIL
echo SYSTEM FREEZE FAILED
:END

'thaw.cmd' (this will fail because the % will get stripped. ::sad face::) 
rem Now unfreeze the system
..\bin\cache -s. -U%SYS ##Class(Backup.General).ExternalThaw()

#Tips & Tricks #Caché

Source URL:https://community.intersystems.com/post/freeze-thaw-scripts-windows-gotcha