Popo95
21-02-2015, 19:26
Salve a tutti!
Sto sviluppando un software che al caricamento del form principale deve avviare in sequenza una serie di software. In sostanza è una specie di installer. Il problema che mi si presenta però è che i programmi vengono avviati prima che il form venga mostrato. Posto il codice:
Imports System.Diagnostics
Public Class Form1
Dim TotalAppsAmount As Integer
Private Function GetAppsNumber() As Integer 'Funzione che conta il numero di applicazioni da installare
Dim Num As Integer
Dim i As Integer = 0
Dim CurrentAppPath As String
Dim CurrentAppName As String
Do While i <= 50
CurrentAppPath = IniRead(Application.StartupPath & "\SETTINGS.ini", "Software", "Path" & i)
CurrentAppName = IniRead(Application.StartupPath & "\SETTINGS.ini", "Software", "Name" & i)
If CurrentAppPath <> "" Then
Num += 1
Else
Exit Do
End If
i += 1
Loop
Return (Num)
End Function
Private Sub InstallApps(ByVal AppsAmount As Integer)
Dim AppName As String
Dim AppPath As String
Dim j As Integer = 0
Do While j <= AppsAmount
AppName = IniRead(Application.StartupPath & "\SETTINGS.ini", "Software", "Name" & j)
AppPath = IniRead(Application.StartupPath & "\SETTINGS.ini", "Software", "Path" & j)
lbl_app_name.Text = AppName
lbl_app_name.Anchor = AnchorStyles.None
lbl_app_amount.Text = "Installazione" & " " & j & " " & "di" & " " & AppsAmount
Process.Start(AppPath)
pbr_installation.Value += 1
j += 1
Loop
End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
TotalAppsAmount = GetAppsNumber()
pbr_installation.Minimum = 0
pbr_installation.Maximum = TotalAppsAmount
InstallApps(TotalAppsAmount)
End Sub
End Class
Quindi il form viene mostrato solo a procedura terminata, io invece voglio che sia sempre mostrato.
Inoltre ho un secondo problema. Utilizzando il Process.Start le applicazioni mi vengono aperte tutte in contemporanea. C'è un modo alternativo per far avviare un'applicazione SOLO se quella precedente è stata chiusa? Ho provato a fare come spiegato in questo articolo ma non funziona: http://support.microsoft.com/kb/305368/it
Come posso fare?
Grazie in anticipo :D
Sto sviluppando un software che al caricamento del form principale deve avviare in sequenza una serie di software. In sostanza è una specie di installer. Il problema che mi si presenta però è che i programmi vengono avviati prima che il form venga mostrato. Posto il codice:
Imports System.Diagnostics
Public Class Form1
Dim TotalAppsAmount As Integer
Private Function GetAppsNumber() As Integer 'Funzione che conta il numero di applicazioni da installare
Dim Num As Integer
Dim i As Integer = 0
Dim CurrentAppPath As String
Dim CurrentAppName As String
Do While i <= 50
CurrentAppPath = IniRead(Application.StartupPath & "\SETTINGS.ini", "Software", "Path" & i)
CurrentAppName = IniRead(Application.StartupPath & "\SETTINGS.ini", "Software", "Name" & i)
If CurrentAppPath <> "" Then
Num += 1
Else
Exit Do
End If
i += 1
Loop
Return (Num)
End Function
Private Sub InstallApps(ByVal AppsAmount As Integer)
Dim AppName As String
Dim AppPath As String
Dim j As Integer = 0
Do While j <= AppsAmount
AppName = IniRead(Application.StartupPath & "\SETTINGS.ini", "Software", "Name" & j)
AppPath = IniRead(Application.StartupPath & "\SETTINGS.ini", "Software", "Path" & j)
lbl_app_name.Text = AppName
lbl_app_name.Anchor = AnchorStyles.None
lbl_app_amount.Text = "Installazione" & " " & j & " " & "di" & " " & AppsAmount
Process.Start(AppPath)
pbr_installation.Value += 1
j += 1
Loop
End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
TotalAppsAmount = GetAppsNumber()
pbr_installation.Minimum = 0
pbr_installation.Maximum = TotalAppsAmount
InstallApps(TotalAppsAmount)
End Sub
End Class
Quindi il form viene mostrato solo a procedura terminata, io invece voglio che sia sempre mostrato.
Inoltre ho un secondo problema. Utilizzando il Process.Start le applicazioni mi vengono aperte tutte in contemporanea. C'è un modo alternativo per far avviare un'applicazione SOLO se quella precedente è stata chiusa? Ho provato a fare come spiegato in questo articolo ma non funziona: http://support.microsoft.com/kb/305368/it
Come posso fare?
Grazie in anticipo :D