Private Sub Command1_Click()
  'Shell "c:\windows\command\attrib.exe +s +h +r c:\netlog.txt", vbNormalFocus '打开DOS窗口
  Shell "c:\windows\command\attrib.exe +s +h +r c:\netlog.txt", vbHide '隐藏DOS窗口
End Sub

解决方案 »

  1.   

    Shell 函数
          执行一个可执行文件,返回一个 Variant (Double),如果成功的话,代表这个程序的任务 ID,若不成功,则会返回 0。语法Shell(pathname[,windowstyle])Shell 函数的语法含有下面这些命名参数:部分 描述 
    pathname 必要参数。Variant (String),要执行的程序名,以及任何必需的参数或命令行变量,可能还包括目录或文件夹,以及驱动器。 
    Windowstyle 可选参数。Variant (Integer),表示在程序运行时窗口的样式。如果 windowstyle 省略,则程序是以具有焦点的最小化窗口来执行的。 
    windowstyle 命名参数有以下这些值:常量 值 描述 
    vbHide 0 窗口被隐藏,且焦点会移到隐式窗口。 
    VbNormalFocus 1 窗口具有焦点,且会还原到它原来的大小和位置。 
    VbMinimizedFocus 2 窗口会以一个具有焦点的图标来显示。 
    VbMaximizedFocus 3 窗口是一个具有焦点的最大化窗口。 
    VbNormalNoFocus 4 窗口会被还原到最近使用的大小和位置,而当前活动的窗口仍然保持活动。 
    VbMinimizedNoFocus 6 窗口会以一个图标来显示。而当前活动的的窗口仍然保持活动。 
    说明如果 Shell 函数成功地执行了所要执行的文件,则它会返回程序的任务 ID。任务 ID 是一个唯一的数值,用来指明正在运行的程序。如果 Shell 函数不能打开命名的程序,则会产生错误。注意 缺省情况下,Shell 函数是以异步方式来执行其它程序的。也就是说,用 Shell 启动的程序可能还没有完成执行过程,就已经执行到 Shell 函数之后的语句。Shell 函数示例
    本示例使用 Shell 函数来完成一个用户指定的应用程序。' 将第二个参数值设成 1,可让该程序以正常大小的窗口完成,并且拥有焦点。
    Dim RetVal
    RetVal = Shell("C:\WINDOWS\CALC.EXE", 1)   ' 完成Calculator。
      

  2.   

    用这个函数:
    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参数:lpParameters就是传给程序的参数。
    如:shellexecute form1.hwnd,"open","C:\windows\notepad.exe","c:\test.txt",,vbnormalfocus
    函数执行后将调用记事本打开“c:\test.txt”
    具体的参数说明及返回值如下:
    参数:
    ?hwnd
    Specifies a parent window. This window receives any message boxes that an application produces. For example, an application may report an error by producing a message box.?lpOperation
    Pointer to a null-terminated string that specifies the operation to perform. The following operation strings are valid:
    搊pen?
     The function opens the file specified by lpFile. The file can be an executable file or a document file. The file can be a folder to open.
    損rint?
     The function prints the file specified by lpFile. The file should be a document file. If the file is an executable file, the function opens the file, as if 搊pen?had been specified.
    揺xplore?
     The function explores the folder specified by lpFile.The lpOperation parameter can be NULL. In that case, the function opens the file specified by lpFile.?lpFile
    Pointer to a null-terminated string that specifies the file to open or print or the folder to open or explore. The function can open an executable file or a document file. The function can print a document file.?lpParameters
    If lpFile specifies an executable file, lpParameters is a pointer to a null-terminated string that specifies parameters to be passed to the application.
    If lpFile specifies a document file, lpParameters should be NULL.?lpDirectory
    Pointer to a null-terminated string that specifies the default directory.?nShowCmd
    If lpFile specifies an executable file, nShowCmd specifies how the application is to be shown when it is opened. This parameter can be one of the following values:
    SW_HIDE
     Hides the window and activates another window.
    SW_MAXIMIZE
     Maximizes the specified window.
    SW_MINIMIZE
     Minimizes the specified window and activates the next top-level window in the Z order.
    SW_RESTORE
     Activates and displays the window. If the window is minimized or maximized, Windows restores it to its original size and position. An application should specify this flag when restoring a minimized window.
    SW_SHOW
     Activates the window and displays it in its current size and position.
    SW_SHOWDEFAULT
     Sets the show state based on the SW_ flag specified in the STARTUPINFO structure passed to the CreateProcess function by the program that started the application. An application should call ShowWindow with this flag to set the initial show state of its main window.
    SW_SHOWMAXIMIZED
     Activates the window and displays it as a maximized window.
    SW_SHOWMINIMIZED
     Activates the window and displays it as a minimized window.
    SW_SHOWMINNOACTIVE
     Displays the window as a minimized window. The active window remains active.
    SW_SHOWNA
     Displays the window in its current state. The active window remains active.
    SW_SHOWNOACTIVATE
     Displays a window in its most recent size and position. The active window remains active.
    SW_SHOWNORMAL
     Activates and displays a window. If the window is minimized or maximized, Windows restores it to its original size and position. An application should specify this flag when displaying the window for the first time.If lpFile specifies a document file, nShowCmd should be zero.返回值:
    If the function succeeds, the return value is the instance handle of the application that was run, or the handle of a dynamic data exchange (DDE) server application. If the function fails, the return value is an error value that is less than or equal to 32. The following table lists these error values:

     The operating system is out of memory or resources. 
     
    ERROR_FILE_NOT_FOUND 
     The specified file was not found. 
     
    ERROR_PATH_NOT_FOUND 
     The specified path was not found. 
     
    ERROR_BAD_FORMAT 
     The .EXE file is invalid (non-Win32 .EXE or error in .EXE image). 
     
    SE_ERR_ACCESSDENIED 
     The operating system denied access to the specified file. 
     
    SE_ERR_ASSOCINCOMPLETE 
     The filename association is incomplete or invalid. 
     
    SE_ERR_DDEBUSY 
     The DDE transaction could not be completed because other DDE transactions were being processed. 
     
    SE_ERR_DDEFAIL 
     The DDE transaction failed. 
     
    SE_ERR_DDETIMEOUT 
     The DDE transaction could not be completed because the request timed out. 
     
    SE_ERR_DLLNOTFOUND 
     The specified dynamic-link library was not found. 
     
    SE_ERR_FNF 
     The specified file was not found. 
     
    SE_ERR_NOASSOC 
     There is no application associated with the given filename extension. 
     
    SE_ERR_OOM 
     There was not enough memory to complete the operation. 
     
    SE_ERR_PNF 
     The specified path was not found. 
     
    SE_ERR_SHARE 
     A sharing violation occurred.
      

  3.   

    你可以使用sendkey或sendmessage函数给对应的程序传递参数!