File tree Expand file tree Collapse file tree 1 file changed +37
-0
lines changed
Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Original file line number Diff line number Diff line change 1+ using System ;
2+ using System . Diagnostics ;
3+ using System . Drawing ;
4+ using System . Windows . Forms ;
5+
6+ class Program
7+ {
8+ static void Main ( )
9+ {
10+ NotifyIcon trayIcon = new NotifyIcon
11+ {
12+ Icon = SystemIcons . Application ,
13+ Text = "VirtualBox VM Control" ,
14+ Visible = true
15+ } ;
16+
17+ ContextMenu trayMenu = new ContextMenu ( ) ;
18+ trayMenu . MenuItems . Add ( "Start VM" , StartVM ) ;
19+ trayMenu . MenuItems . Add ( "Stop VM" , StopVM ) ;
20+ trayMenu . MenuItems . Add ( "Exit" , ( sender , e ) => Application . Exit ( ) ) ;
21+
22+ trayIcon . ContextMenu = trayMenu ;
23+
24+ Application . Run ( ) ;
25+ trayIcon . Dispose ( ) ;
26+ }
27+
28+ static void StartVM ( object sender , EventArgs e )
29+ {
30+ Process . Start ( "VBoxManage" , "startvm \" Your_VM_Name\" --type headless" ) ;
31+ }
32+
33+ static void StopVM ( object sender , EventArgs e )
34+ {
35+ Process . Start ( "VBoxManage" , "controlvm \" Your_VM_Name\" poweroff" ) ;
36+ }
37+ }
You can’t perform that action at this time.
0 commit comments