Results 1 to 11 of 11

Thread: Problem Running Application Using Shell Command

  1. #1

    Thread Starter
    Member
    Join Date
    Jun 2005
    Posts
    35

    Resolved Problem Running Application Using Shell Command

    Hi, running application in vb made my project easy by using Shell(appPath,windowstate) command.

    now, i got a list of applications in my database with its correct path, the prob is, when i try to run those application one-by-one, they all run except for one application which is the most important applications for my client pc (because it is the most favorite application of my costumers), but the program runs abnormally when i run it using shell command, i checked the application's path, but it is correct, when i try to run that application w/o my prog, it ran normally, even its shortcut on my desktop, normal!

    What probablly the problem is??

    I think it's not with my code, cuz the other application runs normaly, except with that application. BDY, the application i am talkin' bout is a game application, do you know MU Online? by Mobius? it is an online game like Ragnarok!!! also ragnarok runs normally in my project, except really MU...

    But when i compiled my program and create the exe file, i try to paste that exe program to the folder where MU resides, then i run my prog, then click the button, THEN iT RAN NORMALLY!?!?!... i check out the properties of MU's shortcut in my desktop, there I see 2 paths: the "target" path w/c is the whole path of the application including the mu.exe file, the other is the "start in" path, where also display the application path but excluding the mu.exe file.

    i think the problem is within the application i am trying to run, not in my program, or maybe there is something wrong with the shell command, maybe parameters or sumthin'....

    does anyone encounter this type of problem???

    then if so, can you share it to this forum, so that i can find a solution to my problem... and it will gladly appreciated!!!... thanx....

    BuB'
    Last edited by Apollyon255; Jun 20th, 2005 at 12:24 PM. Reason: Resolved

  2. #2
    Next Of Kin baja_yu's Avatar
    Join Date
    Aug 2002
    Location
    /dev/root
    Posts
    5,989

    Re: Problem Running Application Using Shell Command

    Try running it with ShellExecute API.

  3. #3
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Problem Running Application Using Shell Command

    The "start in" path is the working directory for your app.

    baja yu suggestion to use the ShellExecute API allows you to specify the working directory. Shell doesnt.
    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 PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI 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

  4. #4

    Thread Starter
    Member
    Join Date
    Jun 2005
    Posts
    35

    Re: Problem Running Application Using Shell Command

    Thankz for reply...

    i don't know how to use that API call or function, i ain't got any code for using it..
    but if you have or know, then please do post it here...

    appreciated...

  5. #5
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Problem Running Application Using Shell Command

    Test.txt is located on my D drive but because I specify the working directory (D:\) it can find the text file in there
    without specifing the entire path.

    VB Code:
    1. Option Explicit
    2.  
    3. Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, _
    4. ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
    5.  
    6. Private Const SW_SHOWNORMAL As Long = 1
    7.  
    8. Private Sub Command1_Click()
    9.     ShellExecute Me.hwnd, "Open", "C:\Windows\Notepad.exe", "Test.txt", "D:\", SW_SHOWNORMAL
    10. 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 PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI 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

  6. #6

    Thread Starter
    Member
    Join Date
    Jun 2005
    Posts
    35

    Re: Problem Running Application Using Shell Command

    thankz, i'll try the code now, and reply imediately the results....
    thnkx for reply...

  7. #7

    Thread Starter
    Member
    Join Date
    Jun 2005
    Posts
    35

    Re: Problem Running Application Using Shell Command

    WoW!!!! thats realy workz!!! i don't even think about using an API call for that prob...
    Thankz a millon!!!! Really appreciated... this forum site really good!!!...

    i'm really still juz a beginner!!! hehehe....

  8. #8
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Problem Running Application Using Shell Command

    baja_yu should get some credit too for suggesting the API.
    I just showed you how to use it.

    Ps, dont forget to 'Resolve' your thread so others will know its been solved.
    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 PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI 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

  9. #9

    Thread Starter
    Member
    Join Date
    Jun 2005
    Posts
    35

    Re: Problem Running Application Using Shell Command

    Yeah, OK i did, but last one... can you explain me the parameters used in that API call function (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) so that i can improvized my way of running application!, i know the use of lpFile, lpParameters and lpDirectory, the others, nope... can you? and advice me for other feature and uses of this API call... cuz it is really my first time to use an API call or function... Thnx again...

    BuB'

  10. #10
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Problem Running Application Using Shell Command

    Sure no problem.

    The first parameter is the owner of the to be sheelled process. Usually you can make the form that is shelling it as the owner - Me.hWnd.

    The second parameter is the operation you want shellexecute to perform. You can do an "Open" or a "Print" if its a printable file.
    For ex. if you shellexecute'd notepad and passed a textfile as the parameter and specified "Print" then it would not open and display
    notepad but rather only print the textfile.

    The last parameter nShowCmd is for the windowstate you want it to be shelled in. Either show normal, minimized, maximized, or hidden
    or a few other minor variations.
    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 PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI 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

  11. #11

    Thread Starter
    Member
    Join Date
    Jun 2005
    Posts
    35

    Re: Problem Running Application Using Shell Command

    Thankx very much.. Got It...
    'til next time...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width