I’m using Sublime Text 3 Build 3083 on Windows 7 Professional, SP1, 64-bit.
If I attempt to use the “Build” functionality to run a PowerShell script that displays an InputBox, the InputBox is not displayed, the script does not finish, and the “powershell.exe” process is orphaned. This does not occur if I run the script outside of ST3 (e.g. via the Windows Explorer “Run with PowerShell” context menu, or via Windows PowerShell ISE), in which case the script functions exactly as expected. I am not very familiar with the “Build” functionality, but I am using what I assume to be the default Build System for PowerShell, as the “Tools -> Build System” option is set to “Automatic”, and the Syntax is “PowerShell”.
I have noticed that for some reason, if the script displays a MessageBox before attempting to display the InputBox, the issue does not occur, and the script runs as expected when executed via ST3 Build. This is merely a workaround, as I do not wish for my script to display an unnecessary MessageBox, but perhaps that info would be useful for debugging purposes.
The sample script below illustrates the issue. Is this something that can be fixed?
# load MessageBox assembly
[System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms") | Out-Null
# display MessageBox
# [System.Windows.Forms.MessageBox]::Show("MessageBox Text", "Text", 0, 64) | Out-Null # Workaround: Uncomment this line
# load InputBox assembly
[System.Reflection.Assembly]::LoadWithPartialName('Microsoft.VisualBasic') | Out-Null
# display InputBox
$input = [Microsoft.VisualBasic.Interaction]::InputBox("Enter some text:", "Enter Text", "Default text")
# output InputBox result
Write-Host $input