use Win32::Process; use Win32; use Tk; $cmd = "utest.bat"; # Spawned command $mw = MainWindow->new( ); my $mylbl = $mw->Label(-text => 'Click Start')->pack( ); my $olbl = $mw->Label(-text => "(no output)")->pack( ); $mw->Button(-text => "Exit", -command => sub { exit })->pack( ); my $mybtn = $mw->Button( -text => 'Start', -command => \&myjob )->pack( ); MainLoop; sub myjob { $mylbl->configure(-text => 'Running...'); &myjob2; # Option 1 # my @res = `$cmd`; # Option 2 # $olbl->configure(-text => $res[0]); # Option 2 $mylbl->configure(-text => 'Completed!', -foreground => 'red'); } sub myjob2 { Win32::Process::Create($ProcessObj, "C:\\windows\\system32\\notepad.exe", "notepad c:\\tmp\\temp.txt", 0, NORMAL_PRIORITY_CLASS, ".")|| die ErrorReport(); $ProcessObj->Wait(INFINITE); } sub ErrorReport{ print Win32::FormatMessage( Win32::GetLastError() ); } #### @echo off sleep -t 5 echo SLEEP IS DONE