Page 1 of 2
command to open up exe in vb
Posted: Fri Feb 18, 2005 4:32 pm
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
Posted: Fri Feb 18, 2005 4:52 pm
by Cheech|N|Chong
i've heard it has something to do with a "shell" command
Posted: Fri Feb 18, 2005 5:12 pm
by Jefff
Yeah, shell whatever. For example:
or
Posted: Sat Feb 19, 2005 2:31 pm
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
Posted: Sat Feb 19, 2005 2:40 pm
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
Posted: Sat Feb 19, 2005 8:14 pm
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.
Posted: Sat Feb 19, 2005 8:29 pm
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
Posted: Sat Feb 19, 2005 8:34 pm
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
Posted: Sat Feb 19, 2005 9:14 pm
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.
Posted: Sat Feb 19, 2005 9:35 pm
by theguy2042000
whats a bas file
Posted: Sun Feb 20, 2005 8:11 am
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:

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.
Posted: Sun Feb 20, 2005 3:22 pm
by theguy2042000
well i have vb6 i just havent installed it on my new computer
Posted: Sun Feb 20, 2005 6:25 pm
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?
Posted: Sun Feb 20, 2005 7:15 pm
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")
Posted: Sun Feb 20, 2005 7:24 pm
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
Posted: Tue Feb 22, 2005 12:21 pm
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.
Posted: Tue Feb 22, 2005 4:04 pm
by theguy2042000
what?
Posted: Tue Feb 22, 2005 4:26 pm
by [CL]9mm-Man
Halo program isnt Halo.exe or halo.exe Its some thing like Halo(1).exe
Posted: Tue Feb 22, 2005 4:28 pm
by theguy2042000
its halo.exe
Posted: Tue Feb 22, 2005 4:31 pm
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