Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Shell-Command

Status
Not open for further replies.

theemperor

Programmer
May 22, 2001
28
AT
Hi all,
I use the Shell-function to execute a batch-file from the commandline. When I step through the code, I get a PID back and I see the Commandline-window for a second in the taskline, but the commands which I declared in the Batchfile are not executed. Does anybody know whether I do something wrong? heres a bit of Code:

nShellRet = Shell(App.Path & "\Test.bat")

Thanx in advance,

Robert
 
Try to insert this on your code module:

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


Public Function StartRunning(strUrl As String) As Long
Dim hWnd As Long
StartRunning = ShellExecute(hWnd, vbNullString, strUrl, vbNullString, vbNullString, vbNormalFocus)

End Function

Then on your code:

StartRunning(App.Path & "\Test.bat")


This should work
 
Thanx for the help! It worked great!

Regards,
Robert
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top