?
Solved

Launching programs

Posted on 2003-03-11
4
Medium Priority
?
215 Views
Last Modified: 2010-05-01
Hey i am trying to internaly launch a program and adding parameters to the end of it i was wondering how i might do this because the shell command im trying isnt working

Example:
exe = hl.exe
want to make it launch: hl.exe -game cstrike +connect 202.123.12.123:7012
0
Comment
Question by:Rinale
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 1

Expert Comment

by:hj2k3
ID: 8116077
use the Shell command, like so:
Shell "hl.exe -game cstrike +connect 202.123.12.123:7012"

hope this helps
0
 
LVL 1

Expert Comment

by:hj2k3
ID: 8116114
...or if that doesn't work, use a batch file with the following contents:

@Echo off
hl.exe -game cstrike +connect 202.123.12.123:7012


save it in notepad at "LaunchCS.bat" or something, as long as it ends in ".bat", then use shell to excecute this, with
Shell "LaunchCS.bat"

the problem might be that you are running the exe but the current path is not correct. so, either use
Chdir "c:\counterstrike"  'or wherever hl.exe is

or to use the batch file, after creating it, right click on it, select properties, goto the 'Program' tab and change 'working' to the directory where hl.exe is in.
0
 
LVL 1

Accepted Solution

by:
SilentRage earned 60 total points
ID: 8116194
shell command should work fine

Shell "hl.exe -game cstrike +connect 202.123.12.123:7012", vbNormalFocus

however, if you're feelin freaky, use the API:

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_SHOWNORMAL = 1

Private Sub Form_Load()
    ShellExecute Me.hwnd, vbNullString, "hl.exe", "-game cstrike +connect 202.123.12.123:7012", "C:\", SW_SHOWNORMAL
End Sub

one last consideration.  Maybe hl.exe isn't in your PATH environment variable.  In other words, it can't find the program.  Use the full path to the executable.  And in the API version, change "C:\" to the directory hl.exe is located in (that way if it uses it's working directory it's pointing to the right place)
0
 

Author Comment

by:Rinale
ID: 8116865
thanks i was lookin 4 the api
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses
Course of the Month12 days, 1 hour left to enroll

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question