One easy way could be :
Implement hook_menu to provide a link to a function
Then in function you can use any code you desire
something like this :
function yourmdoule_menu()
{
$items['test/%'] = array(
'title' => 'Some Function',
'description' => 'Some function will be called by calling it',
'page callback' => 'my_function',
'type' => MENU_CALLBACK,
'access callback' => true,
'page arguments' => array(1),
);
return $items;
}
and then :
function my_function($id = 1){
/// run every want you want
}
so now you can add a button with link to 'test/$nid' and it will call your desired function