command to open up exe in vb

Post here about scripting and programming for HaloPC (audio, network, ai, etc.)
sparkicks





Posts: 151
Joined: Sat May 15, 2004 8:07 am

command to open up exe in vb

Post by sparkicks »

well can someone tell me what the command to open up an exe is in vb? im making a personal program that can start all my programs for me
Cheech|N|Chong





Posts: 115
Joined: Fri Jan 14, 2005 9:26 am
Location: Why The Fuck Would I Tell You? Indiana...
Contact:

Post by Cheech|N|Chong »

i've heard it has something to do with a "shell" command
Signature exceeded 75KB.
Jefff




Socialist Miner Logistician Snitch!
Critic Droplet

Posts: 244
Joined: Sun Oct 24, 2004 5:59 pm

Post by Jefff »

Yeah, shell whatever. For example:

Code: Select all

Shell "notepad.exe"
or

Code: Select all

Shell "C:\program.exe"
How to Post Correctly
SWYgeW91IGNhbiByZWFkIHRoaXMgeW91IGhhdmUgd2F5IHRvIG11Y2ggdGltZSBvbiB5b3VyIGhhbmRz
theguy2042000





Posts: 870
Joined: Tue Nov 09, 2004 10:09 pm
Location: At Home On My Computer
Contact:

Post by theguy2042000 »

it doent work if you run halo
halo says fatal error it says it cant fing your programs config.txt file
how do you fix that
theguy2042000





Posts: 870
Joined: Tue Nov 09, 2004 10:09 pm
Location: At Home On My Computer
Contact:

Post by theguy2042000 »

what is the code to make a config file next to the program you make like if i want to set up the directory for halo and i put like save places it makes a config file and when i start it again the places are gonna be set
Jefff




Socialist Miner Logistician Snitch!
Critic Droplet

Posts: 244
Joined: Sun Oct 24, 2004 5:59 pm

Post by Jefff »

I would just make an ini file. Put this in a bas file:

Code: Select all

Option Explicit

#If Win16 Then
Declare Function WritePrivateProfileString Lib "Kernel" (ByVal AppName As String, ByVal KeyName As String, ByVal NewString As String, ByVal fileName As String) As Integer
Declare Function GetPrivateProfileString Lib "Kernel" Alias "GetPrivateProfilestring" (ByVal AppName As String, ByVal KeyName As Any, ByVal default As String, ByVal ReturnedString As String, ByVal MAXSIZE As Integer, ByVal fileName As String) As Integer
#Else
Declare Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As String, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Long, ByVal lpFileName As String) As Long
Declare Function WritePrivateProfileString Lib "kernel32" Alias "WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As String, ByVal lpString As Any, ByVal lpFileName As String) As Long
#End If

Function ReadINI(Section, KeyName, fileName As String) As String
    Dim sRet As String
    sRet = String(255, Chr(0))
    ReadINI = Left(sRet, GetPrivateProfileString(Section, ByVal KeyName, "", sRet, Len(sRet), fileName))
End Function

Function WriteINI(sSection As String, sKeyName As String, sNewString As String, sFileName) As Integer
    Dim r
    r = WritePrivateProfileString(sSection, sKeyName, sNewString, sFileName)
End Function
Those functions are fairly self explainatory but if you need help using them I will be happy to assist.
How to Post Correctly
SWYgeW91IGNhbiByZWFkIHRoaXMgeW91IGhhdmUgd2F5IHRvIG11Y2ggdGltZSBvbiB5b3VyIGhhbmRz
theguy2042000





Posts: 870
Joined: Tue Nov 09, 2004 10:09 pm
Location: At Home On My Computer
Contact:

Post by theguy2042000 »

thanks for taking the time for writing such a long code thank god for copy paste lol
ill try it if it doenst work ill post agin
theguy2042000





Posts: 870
Joined: Tue Nov 09, 2004 10:09 pm
Location: At Home On My Computer
Contact:

Post by theguy2042000 »

lots of errors lol it has like 15 debug errors
i think that visual basic 2005 changes the code a lot, and not very many people know it
isnt there a shorter code to save a txt file
Jefff




Socialist Miner Logistician Snitch!
Critic Droplet

Posts: 244
Joined: Sun Oct 24, 2004 5:59 pm

Post by Jefff »

Are you sure you put it in a bas file? I don't think it will work otherwise. Anyways, if you do

Code: Select all

ff = FreeFile
Open "c:\test.txt" For Output As ff
Print #ff, "The contents of the textfile"
Close ff
This code is for VB6 so if there are any errors post them.
How to Post Correctly
SWYgeW91IGNhbiByZWFkIHRoaXMgeW91IGhhdmUgd2F5IHRvIG11Y2ggdGltZSBvbiB5b3VyIGhhbmRz
theguy2042000





Posts: 870
Joined: Tue Nov 09, 2004 10:09 pm
Location: At Home On My Computer
Contact:

Post by theguy2042000 »

whats a bas file
Jefff




Socialist Miner Logistician Snitch!
Critic Droplet

Posts: 244
Joined: Sun Oct 24, 2004 5:59 pm

Post by Jefff »

It's like a file that just contains code that is refrenced from your program. Also refered to as a Module. People put functions and other stuff they need, but don't want to get in the way. In VB6, this is how you would add one:
Image
Hopefully it's simular in VB20005. It will then create an empty file. Copy and paste the contents of the ini code and it should work.
Last edited by Jefff on Sun Feb 20, 2005 3:52 pm, edited 1 time in total.
How to Post Correctly
SWYgeW91IGNhbiByZWFkIHRoaXMgeW91IGhhdmUgd2F5IHRvIG11Y2ggdGltZSBvbiB5b3VyIGhhbmRz
theguy2042000





Posts: 870
Joined: Tue Nov 09, 2004 10:09 pm
Location: At Home On My Computer
Contact:

Post by theguy2042000 »

well i have vb6 i just havent installed it on my new computer
theguy2042000





Posts: 870
Joined: Tue Nov 09, 2004 10:09 pm
Location: At Home On My Computer
Contact:

Post by theguy2042000 »

ok i got vb6 on my comp from my old comp had too look for cd for 2 hours lol
ok i made the file and pasted the code in now what?
how do make it it save the config file or will it do it self?
Jefff




Socialist Miner Logistician Snitch!
Critic Droplet

Posts: 244
Joined: Sun Oct 24, 2004 5:59 pm

Post by Jefff »

Use the functions when you want to save or load a setting. For example, lets say MapPath is the path for a map file and you want the program to remember that. Use this command:

Code: Select all

WriteINI("config", "Path", MapPath, App.Path + "\config.ini")
That will make (unless there already is one) a file called config.ini wherever the program is run. Now, say you now want to load the saved MapPath. Use this command:

Code: Select all

MapPath = ReadINI("config", "Path", App.Path + "\config.ini")
How to Post Correctly
SWYgeW91IGNhbiByZWFkIHRoaXMgeW91IGhhdmUgd2F5IHRvIG11Y2ggdGltZSBvbiB5b3VyIGhhbmRz
theguy2042000





Posts: 870
Joined: Tue Nov 09, 2004 10:09 pm
Location: At Home On My Computer
Contact:

Post by theguy2042000 »

so would i write these codes two time becuse i wnat the program to remmenber the path for halo and halo server and the path where to save an init file withch i also dont know how to save the init file
kaptainkommie




Wordewatician 500

Posts: 732
Joined: Wed Nov 26, 2003 11:59 pm
Location: Raleigh, NC, USA

Post by kaptainkommie »

theguy2042000 wrote:it doent work if you run halo
halo says fatal error it says it cant fing your programs config.txt file
how do you fix that
I think you probably need to change your working directory to your Halo directory before you execute Halo.exe. I don't use VB, so I don't know how you would do that, but it should fix it.
theguy2042000





Posts: 870
Joined: Tue Nov 09, 2004 10:09 pm
Location: At Home On My Computer
Contact:

Post by theguy2042000 »

what?
[CL]9mm-Man




Wordewatician 500

Posts: 773
Joined: Tue May 04, 2004 7:14 am
Location: Uranus

Post by [CL]9mm-Man »

Halo program isnt Halo.exe or halo.exe Its some thing like Halo(1).exe
Your image cannot exceed 400x200 or 50kb
theguy2042000





Posts: 870
Joined: Tue Nov 09, 2004 10:09 pm
Location: At Home On My Computer
Contact:

Post by theguy2042000 »

its halo.exe
[CL]9mm-Man




Wordewatician 500

Posts: 773
Joined: Tue May 04, 2004 7:14 am
Location: Uranus

Post by [CL]9mm-Man »

Think what you want. I have coding for a program that works on halo and the start is

Code: Select all

Private Sub Form_Load()
graphscale = 75
hWndConsole = HaloMemory.FindWindow(vbNullString, "Halo Console (1)")
HaloMemory.GetWindowThreadProcessId hWndConsole, pID
cboplayers.ListIndex = 0
End Sub
Your image cannot exceed 400x200 or 50kb
Post Reply