|
-
May 11th, 2007, 05:00 AM
#1
Thread Starter
New Member
Shell Problem with command line arguments VB6
Hi
I am new to VB6 programming.
I am stuck with Shell command. I want to run a EXE with command line arguments i.e.
Shell ("c:\myapplication.exe argument1 argument2") but it does not work. Project runs but nothing happens.
When i run it without any arguments i.e.
Shell ("c:\myapplication.exe") it works.
Please help ASAP and tell me a way out Please.
regards
SAM
PS:And if I run it in Windows->Start->Run as c:\myapplication.exe argument1 argument2 the also it works fine.
-
May 11th, 2007, 05:04 AM
#2
Re: Shell Problem with command line arguments VB6
I don't think the Shell function supports arguments maybe try using the ShellExecute API.
-
May 11th, 2007, 05:12 AM
#3
Thread Starter
New Member
Re: Shell Problem with command line arguments VB6
Thanks
Do u have any codes that can solve my problem ?
thanks
-
May 11th, 2007, 05:19 AM
#4
Re: Shell Problem with command line arguments VB6
vb Code:
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 Button1_Click()
ShellExecute "app.path and file ....... arguments etc...."
End Sub
-
May 11th, 2007, 06:49 AM
#5
Thread Starter
New Member
Re: Shell Problem with command line arguments VB6
Thanks a lot for the code but it somehow didnt work. I am sure i am putting some wrong syntax.
When I tried is as below then it didn't work
ShellExecute "c:\myapplication.exe argument1 argument2 "
Could uou please write a proper syntax for it.
I want to run exactly like this i.e.
c:\myapplication.exe argument1 argument2
Many thanks
Sam
-
May 11th, 2007, 10:01 AM
#6
Re: Shell Problem with command line arguments VB6
Have a look at this article.
-
May 11th, 2007, 10:15 AM
#7
Re: Shell Problem with command line arguments VB6
Its best if you add some kind of delimiter to your arguments. 
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_HIDE As Long = 0
Private Const SW_SHOWNORMAL As Long = 1
Private Const SW_SHOWMAXIMIZED As Long = 3
Private Const SW_SHOWMINIMIZED As Long = 2
Private Sub Command1_Click()
ShellExecute Me.hwnd, "runas", "C:\MyFile.exe", "/Arg1 /Arg2", "C:\", SW_SHOWNORMAL
End Sub
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|