Results 1 to 14 of 14

Thread: Shell Function

  1. #1

    Thread Starter
    Hyperactive Member rEaL iGoR's Avatar
    Join Date
    Apr 2001
    Location
    A secret!
    Posts
    417

    Shell Function

    When I try to run a file with the Shell Function, I get an error message. Apparently, I cannot find the rest of the app. What's wrong
    VB, ADO, SQL, 3DSMAX, DHTML, VBscript, Javascript, CSS

    -Lars Espen Rosness

  2. #2
    Open a program (EXE) or a document (BMP, DOC, JPG, etc.)?

  3. #3

    Thread Starter
    Hyperactive Member rEaL iGoR's Avatar
    Join Date
    Apr 2001
    Location
    A secret!
    Posts
    417
    A program (with the EXE extension). The problem is that the program has to load an .ini file in that very same directory. But the program cannot find that file when the directory is set to my app. How can I change that. I know there's a way...
    VB, ADO, SQL, 3DSMAX, DHTML, VBscript, Javascript, CSS

    -Lars Espen Rosness

  4. #4
    Fanatic Member Patoooey's Avatar
    Join Date
    Aug 2001
    Location
    New Jersey, USA
    Posts
    774
    Post the code giving the problem and the exact error.

  5. #5

    Thread Starter
    Hyperactive Member rEaL iGoR's Avatar
    Join Date
    Apr 2001
    Location
    A secret!
    Posts
    417
    VB Code:
    1. Private Sub Form_Load()
    2. Me.Show
    3. Label1.FontBold = True
    4. Shell "C:\PunkBuster\PB.exe", vbNormalNoFocus
    5. Label1.FontBold = False
    6. End Sub

    Dette er koden
    VB, ADO, SQL, 3DSMAX, DHTML, VBscript, Javascript, CSS

    -Lars Espen Rosness

  6. #6
    Fanatic Member Patoooey's Avatar
    Join Date
    Aug 2001
    Location
    New Jersey, USA
    Posts
    774
    Obviously, I don't have your "C:\PunkBuster\PB.exe" to test but I tried several different applications. Small to large to see if maybe a timing problem. All worked fine.

    Nothing wrong with that code.....The PB.exe file runs ok on it's own ??

  7. #7

    Thread Starter
    Hyperactive Member rEaL iGoR's Avatar
    Join Date
    Apr 2001
    Location
    A secret!
    Posts
    417
    No, that's the problem. It requires the Pb.ini file. When I run the file from my app, the program Pb.exe does'nt understand to look for it in the PB.exe directory.
    VB, ADO, SQL, 3DSMAX, DHTML, VBscript, Javascript, CSS

    -Lars Espen Rosness

  8. #8
    Frenzied Member nishantp's Avatar
    Join Date
    Jan 2001
    Location
    Where you least expect me to be
    Posts
    1,375
    VB Code:
    1. ChDir "C:\PunkBuster"
    You just proved that sig advertisements work.

  9. #9
    Fanatic Member rudvs2's Avatar
    Join Date
    Mar 2001
    Location
    NZ
    Posts
    935
    or you could use the shellexecuteex api

  10. #10

    Thread Starter
    Hyperactive Member rEaL iGoR's Avatar
    Join Date
    Apr 2001
    Location
    A secret!
    Posts
    417
    But that makes it a whole lot more complicated(Which I don't want, especially since I've never used or done any API...I don't even yet know what it is and what it's used for)

    But thanks anyway!
    VB, ADO, SQL, 3DSMAX, DHTML, VBscript, Javascript, CSS

    -Lars Espen Rosness

  11. #11
    Frenzied Member nishantp's Avatar
    Join Date
    Jan 2001
    Location
    Where you least expect me to be
    Posts
    1,375
    Before you open the .ini file, use ChDir to change to its directory, whatever that may be.
    You just proved that sig advertisements work.

  12. #12

    Thread Starter
    Hyperactive Member rEaL iGoR's Avatar
    Join Date
    Apr 2001
    Location
    A secret!
    Posts
    417
    Yes, I know. Thank you
    VB, ADO, SQL, 3DSMAX, DHTML, VBscript, Javascript, CSS

    -Lars Espen Rosness

  13. #13
    Frenzied Member nishantp's Avatar
    Join Date
    Jan 2001
    Location
    Where you least expect me to be
    Posts
    1,375
    well i was just wondering whether it solved your problem...
    You just proved that sig advertisements work.

  14. #14
    PowerPoster eiSecure's Avatar
    Join Date
    Jul 2000
    Location
    Texas
    Posts
    2,209
    ShellExecute is not complicated at all.

    Just put this under General Declarations:
    VB Code:
    1. 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
    It may seem long, but you can just copy & paste it in there.

    Next, put this to replace your current Form_Load() event:
    VB Code:
    1. Private Sub Form_Load()
    2.     Me.Show
    3.     Label1.FontBold = True
    4.     ShellExecute hwnd, "open", "C:\PunkBuster\PB.exe", "", "", 1
    5.     Label1.FontBold = False
    6. End Sub

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