Intégrer une variable à une commande windows en vb.net
Résolu
LaCigale
Messages postés
5
Statut
Membre
-
LaCigale Messages postés 5 Statut Membre -
LaCigale Messages postés 5 Statut Membre -
Bonjour,
Sauriez-vous comment intégrer la variable TotalSec a la commande Shutdown ci dessous pour que la commande exécutée soit : shutdown -s -t (valeur de TotalSec) ?
Voila mon code:
D'avance merci pour toute aide!!
Sauriez-vous comment intégrer la variable TotalSec a la commande Shutdown ci dessous pour que la commande exécutée soit : shutdown -s -t (valeur de TotalSec) ?
Voila mon code:
Dim TotalSec As Integer
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles StartButton.Click
TotalSec = 50 'valeur de TotalSec
Dim myProcess As New Process()
myProcess.StartInfo.FileName = "cmd.exe"
myProcess.StartInfo.Arguments = "/c shutdown -s -t (TotalSec) " 'Commande a exécuter
myProcess.StartInfo.CreateNoWindow = True
myProcess.StartInfo.WindowStyle = ProcessWindowStyle.Hidden
myProcess.Start() 'lance le process
myProcess.WaitForExit() 'attend qu'il soit terminé avant d'aller plus loin
myProcess.Close() 'ferme le process
End Sub
D'avance merci pour toute aide!!
A voir également:
- Intégrer une variable à une commande windows en vb.net
- Invite de commande windows - Guide
- Clé d'activation windows 10 - Guide
- Desinstaller une application sur windows - Guide
- Montage video gratuit windows - Guide
- Windows ne démarre pas - Guide
Public Sub Shutdown() Conversion() Dim myProcess As New Process() myProcess.StartInfo.FileName = "cmd.exe" 'l'application myProcess.StartInfo.Arguments = String.Format(" /c shutdown -s -t {0}", TotalSec) myProcess.StartInfo.CreateNoWindow = True myProcess.StartInfo.WindowStyle = ProcessWindowStyle.Hidden myProcess.Start() 'lance le process myProcess.WaitForExit() 'attend qu'il soit terminé avant d'aller plus loin myProcess.Close() 'ferme le process ResultLabel.Text = String.Format("Windows s'éteindra dans {0} heure(s) et {1} Minute(s).", NumericUpDownHeure.Value, NumericUpDownMinute.Value) End SubA+