所以我創建了一個帶有按鈕的窗口,但我想在窗口中爲某些函數嵌套一個shell,而不是打開一個新窗口。在表格中使用Powershell
例如,腳本的不同部分提示用戶輸入目標,然後對該計算機執行命令。我想要做所有這些,從這種形式的殼
Add-Type -AssemblyName System.Windows.Forms
$Form = New-Object system.Windows.Forms.Form
$Form.Text = "Dan's Security Tool"
$Icon = New-Object system.drawing.icon
("c:\users\sadmiller2\documents\icon.ico")
$Form.Icon = $Icon
$Image =
[system.drawing.image]::FromFile("c:\users\sadmiller2\pictures\defender.jpg")
$Form.BackgroundImage = $Image
$Form.BackgroundImageLayout = "None"
# None, Tile, Center, Stretch, Zoom
$Form.Width = $Image.Width
$Form.Height = $Image.Height
$Font = New-Object System.Drawing.Font("Times New Roman",20,
[System.Drawing.FontStyle]::Regular)
# Font styles are: Regular, Bold, Italic, Underline, Strikeout
$Form.Font = $Font
$form.StartPosition = "CenterScreen"
$Label = New-Object System.Windows.Forms.Label
$Label.Text = "Dan's Security Tool"
$Label.BackColor = "Transparent"
$Label.ForeColor = "White"
$Label.AutoSize = $True
$Label.Location = New-Object System.Drawing.Point(485,25)
$ContinueButton = New-Object System.Windows.Forms.Button
$ContinueButton.Location = New-Object System.Drawing.Point(530,590)
$ContinueButton.Size = New-Object System.Drawing.Size(130,30)
$ContinueButton.Text = "Continue"
$ContinueButton.Add_MouseHover({$ContinueButton.backcolor = [System.Drawing.Color]::DarkGray})
$ContinueButton.Add_MouseLeave({$ContinueButton.backcolor = [System.Drawing.Color]::White})
$ContinueButton.DialogResult = [System.Windows.Forms.DialogResult]::Cancel
$form.CancelButton = $ContinueButton
$form.Controls.Add($ContinueButton)
$Form.Controls.Add($Label)
$Form.ShowDialog()
輸出可以包含一些代碼,你有什麼到目前爲止已經試過?請參閱[這裏](https://stackoverflow.com/help/how-to-ask)瞭解如何提出最有可能得到有效回答的問題。 – pucky124
您還可以看看Sapien powerShell Studio,Admin Script Editor和Visual Studio 2017.它們都提供了使用PowerShell的GUI構建。 –