You can use the Embedded Event Manager to accomplish this. For example:
event manager applet no_shut_e_0_1
event none
action 1.0 cli command "enable"
action 2.0 cli command "config t"
action 3.0 cli command "int e0/1"
action 4.0 cli command "no shut"
action 5.0 cli command "end"
action 6.0 cli command "write mem"
!
alias exec noshute_0_1 event manager run no_shut_e_0_1
Then, from exec mode, just run:
Router#noshute_0_1
And interface e0/1 will be set administratively up. Note: the "alias exec" is not required, but it makes creating custom IOS commands easier. Without it, you would have to run "event manager run no_shut_e_0_1" each time you wanted to execute the applet.
However, this does not make use of returns codes as you asked about initially. Using return codes together with EEM is also possible. This gives you a way to intercept certain commands, and choose not to run them. For example, to intercept the command "show ip ospf neighbors" and not run it, do:
event manager applet no_ip_ospf_nei
event cli pattern "show ip ospf neighbor" sync yes
action 1.0 syslog msg "DANGER: CLI command $_cli_msg was attempted (but not executed)" priority critical
set 2.0 _exit_status 0
Now when "show ip ospf neighbor" is typed, EEM will intercept it, send out a critical syslog message, and ignore the command.
More about the Embedded Event Manager can be found at http://www.cisco.com/en/US/products/ps6441/products_configuration_guide_book09186a008054dddf.html