You have to put that code inside a function. Executable statements can't be at file scope.
I'm not sure when you want the code to run, but for example if you are trying to run it on startup, you could place it at the end of AppInit2 in init.cpp (before the return statement).