can you call any command at the dos prompt using shell() or is it only certain commands?
Printable View
can you call any command at the dos prompt using shell() or is it only certain commands?
There are no restrictions with shell and a dos command window.
:)
Thank you.
One more question regarding shell().
How do you get the DOS prompt to stay open once opened by vba?
I know there is some property but i cant remember what it is
If you pass the /C after the CMD.exe it will close the window and /K will keep it open.
VB Code:
Option Explicit 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 Const SW_SHOWNORMAL As Long = 1 Private Const SW_SHOWMINIMIZED As Long = 2 Private Const SW_SHOWMAXIMIZED As Long = 3 Private Sub Command1_Click() ShellExecute Me.hwnd, "Open", "C:\Windows\System32\CMD.exe", " /K Dir C:\", App.Path, SW_SHOWNORMAL End Sub