Not quite elegant, but it works (the main loop needs to be called once after ClearAll):
ActionMenu["Clear", {"Clear global variables" :> (ClearAll["Global`*"]; Block[{nb}, nb = CreateDocument[ExpressionCell[42, "Input"], Visible -> False]; SelectionMove[nb, All, Notebook]; SelectionEvaluate[nb]; NotebookDelete[nb];])}]
Of course, you should use the new Mathematica 8 NotebookEvaluate function, but it doesn't seem to work here (i.e.
ActionMenu["Clear", {"Clear global variables" :> (ClearAll["Global`*"]; Block[{nb}, nb = CreateDocument[ExpressionCell[42, "Input"], Visible -> False]; NotebookEvaluate[nb]; NotebookDelete[nb];])}]
error message appears
Could not process unknown packet "1".
source share