Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 216
  • Last Modified:

Launching programs

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
Rinale
Asked:
Rinale
  • 2
1 Solution
 
hj2k3Commented:
use the Shell command, like so:
Shell "hl.exe -game cstrike +connect 202.123.12.123:7012"

hope this helps
0
 
hj2k3Commented:
...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
 
SilentRageCommented:
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
 
RinaleAuthor Commented:
thanks i was lookin 4 the api
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now