added title cmd execution and created start-cmd.ps1

This commit is contained in:
Alessandro Seravalli 2025-07-30 18:18:34 +02:00
parent f93e9eaf69
commit 08b2e3ac1a
2 changed files with 28 additions and 8 deletions

View File

@ -136,7 +136,7 @@ $btnInstall.Add_Click({
return
}
$form.Enabled = $false
$positions = Get-TerminalPositions $modules.Count
# $positions = Get-TerminalPositions $modules.Count
foreach ($mod in $selected) {
$index = [Array]::IndexOf($modules, $mod)
if ($index -lt 0) { continue }
@ -147,10 +147,12 @@ $btnInstall.Add_Click({
[System.Windows.Forms.MessageBox]::Show("Modulo non trovato: $modPathRaw", "Errore", [System.Windows.Forms.MessageBoxButtons]::OK, [System.Windows.Forms.MessageBoxIcon]::Error)
continue
}
$startCmdPosScript = Join-Path $ScriptDir "..\..\general\start-cmd-pos.ps1"
#$startCmdPosScript = Join-Path $ScriptDir "..\..\general\start-cmd-pos.ps1"
$startCmdScript = Join-Path $ScriptDir "..\..\general\start-cmd.ps1"
$cmd = "cd /d $ScriptDir && install.bat `"" + $modPath + "`""
$pos = $positions[$index]
powershell -ExecutionPolicy Bypass -File $startCmdPosScript -CommandLine $cmd -X $pos.X -Y $pos.Y -Width $pos.Width -Height $pos.Height
# $pos = $positions[$index]
# powershell -ExecutionPolicy Bypass -File $startCmdScript -Name "install $mod" -CommandLine $cmd -X $pos.X -Y $pos.Y -Width $pos.Width -Height $pos.Height
powershell -ExecutionPolicy Bypass -File $startCmdScript -Name "install $mod" -CommandLine $cmd
}
[System.Windows.Forms.MessageBox]::Show("Installazione avviata in nuove finestre terminale.", "Info", [System.Windows.Forms.MessageBoxButtons]::OK, [System.Windows.Forms.MessageBoxIcon]::Information)
$form.Enabled = $true
@ -164,7 +166,7 @@ $btnStart.Add_Click({
return
}
$form.Enabled = $false
$positions = Get-TerminalPositions $modules.Count
# $positions = Get-TerminalPositions $modules.Count FIX-ME: non funziona
foreach ($mod in $selected) {
$index = [Array]::IndexOf($modules, $mod)
if ($index -lt 0) { continue }
@ -181,10 +183,12 @@ $btnStart.Add_Click({
[System.Windows.Forms.MessageBox]::Show("Modulo non trovato: $modPathRaw", "Errore", [System.Windows.Forms.MessageBoxButtons]::OK, [System.Windows.Forms.MessageBoxIcon]::Error)
continue
}
$startCmdPosScript = Join-Path $ScriptDir "..\..\general\start-cmd-pos.ps1"
#$startCmdPosScript = Join-Path $ScriptDir "..\..\general\start-cmd-pos.ps1"
$startCmdScript = Join-Path $ScriptDir "..\..\general\start-cmd.ps1"
$cmd = "cd /d $ScriptDir && $batName `"" + $modPath + "`""
$pos = $positions[$index]
powershell -ExecutionPolicy Bypass -File $startCmdPosScript -CommandLine $cmd -X $pos.X -Y $pos.Y -Width $pos.Width -Height $pos.Height
# $pos = $positions[$index]
# powershell -ExecutionPolicy Bypass -File $startCmdPosScript -Name "start $mod" -CommandLine $cmd -X $pos.X -Y $pos.Y -Width $pos.Width -Height $pos.Height
powershell -ExecutionPolicy Bypass -File $startCmdScript -Name "start $mod" -CommandLine $cmd
}
[System.Windows.Forms.MessageBox]::Show("Avvio progetti in nuove finestre terminale.", "Info", [System.Windows.Forms.MessageBoxButtons]::OK, [System.Windows.Forms.MessageBoxIcon]::Information)
$form.Enabled = $true

16
src/general/start-cmd.ps1 Normal file
View File

@ -0,0 +1,16 @@
param(
[Parameter(Mandatory=$true)]
[string]$CommandLine,
[Parameter(Mandatory=$false)]
[string]$Name
)
# Prepara la command line con il titolo, se richiesto
if ($Name) {
$cmdline = "title $Name && $CommandLine"
} else {
$cmdline = $CommandLine
}
# Avvia il processo cmd
Start-Process -FilePath "cmd.exe" -ArgumentList "/k $cmdline" -PassThru