如何制作一个简单的Windows程序来启动和停止外部应用程序

凯蒂

启动后,程序应运行shell命令,例如“ C:\ Program File \ Oracle \ VirtualBox \ VBoxManage.exe -startvm ...”

再次启动时,它应运行其他命令,例如“ C:\ Program File \ Oracle \ VirtualBox \ VBoxManage.exe -controlvm ...”

我该如何编写这样的程序?我可以使用哪种语言?我知道一些PHP和javascript,但是这些不能让您创建在Windows下运行的可执行文件:(

指关节-德拉格

我会尝试Powershell。不完全是一个.exe,而是一个.ps1表单(具有3个按钮的GUI),可让您单独运行这些命令。

function KNUCKLE-DRAGGERS-3-BUTTON-FORM {

#region Import the Assemblies
[reflection.assembly]::loadwithpartialname("System.Windows.Forms") | Out-Null
[reflection.assembly]::loadwithpartialname("System.Drawing") | Out-Null
#endregion

#region Generated Form Objects
$form1 = New-Object System.Windows.Forms.Form
$button3 = New-Object System.Windows.Forms.Button
$button2 = New-Object System.Windows.Forms.Button
$button1 = New-Object System.Windows.Forms.Button
$InitialFormWindowState = New-Object System.Windows.Forms.FormWindowState
#endregion Generated Form Objects

#----------------------------------------------
#Generated Event Script Blocks
#----------------------------------------------



$handler_form1_Load= 
{


}



$handler_button1_Click= 
{

###########################################################################################################
#          Button 1 commands                                                                              #
###########################################################################################################

C:\Program File\Oracle\VirtualBox\VBoxManage.exe -startvm 



}

$handler_button2_Click= 
{

###########################################################################################################
#          Button 2 commands                                                                              #
###########################################################################################################

C:\Program File\Oracle\VirtualBox\VBoxManage.exe -controlvm


}

$handler_button3_Click= 
{

###########################################################################################################
#          Button 3 commands                                                                              #
###########################################################################################################


$form1.close()
#Exit

}





$OnLoadForm_StateCorrection=
{#Correct the initial state of the form to prevent the .Net maximized form issue
    $form1.WindowState = $InitialFormWindowState
}

#----------------------------------------------
#region Generated Form Code
$form1.Text = "Knuckle-Dragger Was Here"
$form1.Name = "form1"
$form1.DataBindings.DefaultDataSourceUpdateMode = 0
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Width = 212
$System_Drawing_Size.Height = 176
$form1.ClientSize = $System_Drawing_Size
$form1.add_Load($handler_form1_Load)

$button3.TabIndex = 2
$button3.Name = "button3"
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Width = 140
$System_Drawing_Size.Height = 35
$button3.Size = $System_Drawing_Size
$button3.UseVisualStyleBackColor = $True

$button3.Text = "Exit"

$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 36
$System_Drawing_Point.Y = 114
$button3.Location = $System_Drawing_Point
$button3.DataBindings.DefaultDataSourceUpdateMode = 0
$button3.add_Click($handler_button3_Click)

$form1.Controls.Add($button3)

$button2.TabIndex = 1
$button2.Name = "button2"
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Width = 140
$System_Drawing_Size.Height = 35
$button2.Size = $System_Drawing_Size
$button2.UseVisualStyleBackColor = $True

$button2.Text = "Second Command"

$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 36
$System_Drawing_Point.Y = 71
$button2.Location = $System_Drawing_Point
$button2.DataBindings.DefaultDataSourceUpdateMode = 0
$button2.add_Click($handler_button2_Click)

$form1.Controls.Add($button2)

$button1.TabIndex = 0
$button1.Name = "button1"
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Width = 140
$System_Drawing_Size.Height = 35
$button1.Size = $System_Drawing_Size
$button1.UseVisualStyleBackColor = $True

$button1.Text = "First Command"

$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 36
$System_Drawing_Point.Y = 28
$button1.Location = $System_Drawing_Point
$button1.DataBindings.DefaultDataSourceUpdateMode = 0
$button1.add_Click($handler_button1_Click)

$form1.Controls.Add($button1)

#endregion Generated Form Code

#Save the initial state of the form
$InitialFormWindowState = $form1.WindowState
#Init the OnLoad event to correct the initial state of the form
$form1.add_Load($OnLoadForm_StateCorrection)
#Show the Form
$form1.ShowDialog()| Out-Null

} #End Function


KNUCKLE-DRAGGERS-3-BUTTON-FORM

#

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

如何启动一个简单的下一个应用程序反应

如何使用 android studio 制作一个简单的跟踪 android 应用程序

如何制作一个dist reactjs应用程序?

从另一个应用程序启动外部“不可见”应用程序

如何在 Laravel 应用程序中保存一个简单的 PHP 应用程序?

简单的Java应用程序(3个按钮-每个按钮都会启动和停止计数)

如何在React.JS中创建一个简单的列表制作器应用程序?

如何从另一个应用程序启动iOS相册应用程序?(迅速)

如何离开当前应用程序并启动另一个应用程序的活动?

如何从我的Ubuntu Touch应用程序启动另一个应用程序?

我应该使用 Expo 来制作一个小的交叉平台应用程序吗?

一个按钮的简单android应用程序:“不幸的是-app-已停止”

创建一个程序来更改Windows应用程序的执行

如何在一个文件中创建一个简单的React应用程序?

打开一个外部应用程序并通过明确的活动启动它

我正在制作一个Android节拍器应用程序。但是,播放声音时程序停止

制作一个单罐Java应用程序

如何制作一个简单的程序,使Servlet和JSP一起生成HTML文件?

osX - 如何从我的 QT 应用程序启动另一个程序

是否可以在一个exe中制作GUI和控制台应用程序?

我正在尝试使用 tkinter 和 pysrt 制作一个 GUI 应用程序

创建一个简单的python Web应用程序

运行一个简单的 Falcon 应用程序

我正在尝试制作一个简单的应用程序来比较两个R文件

如何制作一个程序来计算这个方程

eclipse中是否有一个快捷键来启动(喜欢的)外部应用程序,例如参数化的Maven构建?

如何提供一个文件夹来从 Web 应用程序写入和下载临时文件?

如何启动一个锁定屏幕,以防止启动时访问应用程序?

如何在启动应用程序时选择一个活动作为启动活动?