Bonsoir à tous,
Mon problème à l'air simple mais j'ai de grosse difficulté à le faire fonctionner, pouvez vous m'aider ?
Je cherche à exécuter une commande DOS : mklink /J C:\Temp\Rep C:\Temp\Rep1 (Ça créer une jonction Rep qui pointe vers Rep1)
Je précise que j'aimerais éviter qu'une fenêtre DOS s'affiche lors de l’exécution de la commande.
Merci beaucoup pour votre aide.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30 Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click Dim arg As String arg = "mklink /J C:\Temp\Rep C:\Temp\Rep1" Dim File As New IO.FileInfo("C:\Windows\system32\cmd.exe") Execute(File, arg) End Sub Private Sub Execute(AppFile As FileInfo, Arg As String) Dim p As New Process 'Dim retour As String = "" p.StartInfo.UseShellExecute = False p.StartInfo.FileName = "cmd.exe" ' AppFile.FullName p.StartInfo.Arguments = Arg 'p.StartInfo.RedirectStandardOutput = True 'Facultatif, mais peut être nécessaire pour le bon fonctionnement du process 'p.StartInfo.WorkingDirectory = AppFile.DirectoryName 'Facultatif, permet de masquer le process 'p.StartInfo.CreateNoWindow = True p.Start() 'While p.HasExited = False 'retour = p.StandardOutput.ReadToEnd 'End While 'MessageBox.Show(retour) End Sub
Partager