It works in a different way for codeunits. You can’t change company for a codeunit, but can execute it in a separate session which is started in a context of a company specified in the session parameters.
Company.RESET;
IF Company.FINDSET THEN
BEGIN
REPEAT
STARTSESSION(SessionID,CODEUNIT::"Upgrade New Version",Company.Name);
UNTIL Company.NEXT = 0;
MESSAGE('Done !');
END;