Firstly, the cmd /k operation should return an errorlevel of 0 if it was started correctly, so your eventcreate call should happen before your exit , and not after the label :Stoppd as you have in your example.
Secondly, if you want your archiving operation to run as the process spawned by the process, you must put start in front of the cmd line:
start C:\WINDOWS\system32\cmd.exe /K "Archive Full Text Index Service" βoptimize
This will let your process go, and then the current console can continue and fire the 'archive has started' event.
Thirdly, in order to create an event after the completion of the archive operation, you have several options:
you can execute two commands together with & :
start C: \ WINDOWS \ system32 \ cmd.exe / K "Archive Full Text Index Service" βoptimize & eventcreate ...
you could put your archive call and its subsequent eventcreate call in a batch file, and then call it in your cmd /k call.
start C: \ WINDOWS \ system32 \ cmd.exe / K myArchiveAndEventBatch.bat
source share