Results 1 to 6 of 6

Thread: [RESOLVED] Shell command

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2004
    Posts
    541

    Resolved [RESOLVED] Shell command

    Hello

    I'm looking to run a script file I have created using the shell command. It works great for running batch files, but it crashes when I try to use it to run my script file. (The script file is very similiar to how batches run) Here is my code:

    If intVerify(1) = 11500 Then
    MsgBox "11500 does not match"
    Call Shell("S:\MIS\Scripts\Speciality_Fore.msl")

    I really just want VB to open this file. That alone will kick off the script. Any help would be greatly appreciated.

    James

  2. #2
    Frenzied Member
    Join Date
    May 2003
    Location
    So Cal
    Posts
    1,564
    Search on Shellexecute and use that instead of Shell.

  3. #3
    INXSIVE Bruce Fox's Avatar
    Join Date
    Sep 2001
    Location
    Melbourne, Australia
    Posts
    7,429
    To clarify:
    Shell() executes a .exe/application. If you want to open a specific file then
    include the app and file in the Shell. Like Shell appname filename


    Alternatly, (as mentioned) you can use the ShellExecute API.
    It will run the native application associated with the passed file.




    Bruce.

  4. #4
    Fanatic Member laserman's Avatar
    Join Date
    Jan 2002
    Location
    Wales U.K
    Posts
    775
    Her eis the shell execute.

    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
    2. Const SW_SHOWNORMAL = 1
    3. Private Sub Form_Load()
    4.     'KPD-Team 1998
    5.     'URL: [url]http://www.allapi.net/[/url]
    6.     'E-Mail: [email][email protected][/email]
    7.     'Send an E-Mail to the KPD-Team
    8.     ShellExecute Me.hwnd, vbNullString, "mailto:[email protected]", vbNullString, "C:\", SW_SHOWNORMAL
    9. End Sub

  5. #5
    Fanatic Member aconybeare's Avatar
    Join Date
    Oct 2001
    Location
    UK
    Posts
    772

    Shell loads App into Processes and not Desktop?

    Hello,

    I am trying to shell notepad from my app (a service).
    It's telling me that it is loaded, however it is not being displayed on the desktop. I've checked the task manager and it's not there, but it is listed in the processes

    Does anyone know why this is happening? Is there a better way of doing it?

    Here is a my code -

    VB Code:
    1. If Not modAppRunning.CheckForProcByExe(strAppName) Then
    2.         ' Not found start it
    3.         retVal = Shell(notepad.exe, vbNormalFocus)
    4.         If retVal <> 0 Then
    5.             MsgBox "Started by the Service (" & NTService.DisplayName & ")"
    6.         Else
    7.             MsgBox "Error With Launch!"
    8.         End If
    9.     Else
    10.         MsgBox "Already Running"
    11.     End If

    Cheers Al

  6. #6
    Fanatic Member aconybeare's Avatar
    Join Date
    Oct 2001
    Location
    UK
    Posts
    772

    Apologies

    Sorry Guys I mean't to post the above as a new Post and not a reply

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