Brug Windows API funktionen ShellExecute, VB's version af Shell fungerer ikke godt med parametre. Grunden til at du får en fejl, er at der ikke findes en fil, der hedder dir.exe, som Shell kan køre. Dir er en kommando indbygget i kommandofortolkeren cmd.exe eller command.com
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Private Sub Command1_Click() Dim ans As Long ans = ShellExecute(Me.hwnd, "open", "cmd", "/c dir >c:\fil.txt", "", 0) If ans <= 32 Then MsgBox "Error!" End Sub
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.