Hide Dock Icon dynamically

Hiding the Dock Icon and Menubar for apps can easily be done by adding the bellow in the Info.plist file

<key>NSUIElement</key> <string>true</string>

Is there a way to do this dynamically with some declares? Basically I need to hide/unhide the Dock Icon (and Menubar) in-code.

Found it with MBS

dim myProcess as ProcessMBS myProcess=new ProcessMBS myProcess.GetCurrentProcess if myProcess.TransformProcessType(myProcess.kProcessTransformToUIElementApplication) = 0 then end if

To show the Dock Icon again:

if myProcess.TransformProcessType(myProcess.kProcessTransformToForegroundApplication) = 0 then end if