QuestionHelpMaking A Program To Open Another Program - Need Help !

Posts 1–15 of 21 · Page 1 of 2
Making A Program To Open Another Program - Need Help !
Hello , i am a newbie in visual basic ( and also other programming languages ) and i need help ! I am trying to make a program that can add programs to a "ListView" with open file dialog and then the user selects any program from the list and hits a button and the program automatically launches and if the program failed it would use the error provider to give an error telling the user "The program has been moved , changed or deleted ! If the program is still in your machine then please add it to the list again!" , also the user can change the settings by clicking the settings button and maybe refresh the listview and maybe like a checkbox "Close This Program After Launching A Application" plus there would be a button to remove selected application from the listview . . . Please Help ! ( Codes , And A Bit Explaining Helps Please :P )

Here Is What Is Added to The Form . . .
A RichTextBox(Read Only , just for the place to add title and with background color to make the program look good lol . . i love designing ! )
Information Button (dont worry about this)
Exit Application (dont worry about this either)
Settings (btn_settings , opens another form , no need to worry about this !)
Settings Form [Refresh(btn_refresh , to refresh listview) checkbox(checkbox1 , Close this program after launching a application {only if checked}) ]
Remove Button (btn_remove , remove selected application in listview)
Add Button (btn_add , add a application with open file dialog , into the listview)
Launch Selected (btn_launch , launch the application selected/highlighted from the listview)!
ListView (ListView1 , where the applications added using openfiledialog will be and can be removed from here)

The Applications That Will Be Added Will Be Shortcuts Mainly Actually . . .
Only Exe Files . . .

Also , Heres A ScreenShot Of The Interface of the program i am trying to make :
.. use OpenFileDialog and then shell(OpenFileDialog.FileName)
do the rest yourself .. and learn programming before okay?
I didn't really ask you to just go ahead and write the whole coding , cant you just give me a good link ? You know that 2 pieces of line are useless , you just said to use openfiledialog . . . thats it . . . thats not even close to helping . . . its a help request . . thats just rude , if you dont want to answer correctly then please dont ! :/ . . . just explain some coding or just give me a good link ok . . . i have tried to find links but all links that i found mostly just tell you how to do it , they dont explain codings to you , thats why i decided to post this topic here . . sorry if you thought this was rude . . .
lolz .. I gave you the hint to use OpenFileDialog and the other shit with shell. If you dont know anything you srsly shouldnt try to code.
and have you ever heart of google?
google.com
dude you gave me a useless hint . . . i do know i need to use openfiledialog and did use google and i do know what shell is and im trying to code here but kinda failing a bit so thats why just for good guides i posted the topic here . . . please dont give silly answers :/ ! but thanx anyway ^_^ for trying to help .
Put a .exe program in a folder with your primary program and type in code at BUTTON1 :

Code:
Shell("program.exe")

Why was this so hard ?
Or.. you want another method.. PM ME.
Quote Originally Posted by SwissBio View Post
Put a .exe program in a folder with your primary program and type in code at BUTTON1 :

Code:
Shell("program.exe")

Why was this so hard ?
Or.. you want another method.. PM ME.
I always use Process.Start
(works with website links as well)
Quote Originally Posted by Cryptonic View Post


I always use Process.Start
(works with website links as well)
Yep ! I know. But for me is more simply to use that.
You could use 1 of 2 ways. You could use the Shell() Function or the Process.Start() method. Either way, they both would work.
In your case, I see that you're loading items into a list. If you want to open a selected file from that list, you'll need to have that item.tag or one of the columns to have the file path of that item. So, when you want to open that file, you can use one of the 2 methods to open the selected file.

Reading the thread, you seem a bit slow on this topic.

Code:
'To open files to the list
Dim dlg as New OpenFileDialog
With dlg
.MultiSelect = True
.Restore Directory = True
.Filter = "Executible Application(*.exe)|*.exe"
.Title = "Open Files"
End With

If dlg.ShowDialog() = WindowsForms.DialogResult.Ok Then
For each string in dlg.FileNames
Dim item as new ListViewItem(else)
item.SubItems.Add(System. IO.Path.GetFileNameWithoutExtension(ele))
Listview1.Items.Add(item)
Next

'To start the selected file
If My.Coputer.FileSystem.FileExist(Listview1.FocusedItem.Text) Then
Shell(Listview1.FocusedItem.Text) 'Shell also have additional parameters if you want a few more options
End If

'form load event [Mybase.Load]
ListView1.Columns.AddRange(New ColumnHeader() {New ColumnHeader("File Path"), New ColumnHeader("File Name")})
Listview1.MultiSelect = False

I did all this from the top of my head. Should be correct
Quote Originally Posted by GreenPro View Post
Hello , i am a newbie in visual basic ( and also other programming languages ) and i need help ! I am trying to make a program that can add programs to a "ListView" with open file dialog and then the user selects any program from the list and hits a button and the program automatically launches and if the program failed it would use the error provider to give an error telling the user "The program has been moved , changed or deleted ! If the program is still in your machine then please add it to the list again!" , also the user can change the settings by clicking the settings button and maybe refresh the listview and maybe like a checkbox "Close This Program After Launching A Application" plus there would be a button to remove selected application from the listview . . . Please Help ! ( Codes , And A Bit Explaining Helps Please :P )

Here Is What Is Added to The Form . . .
A RichTextBox(Read Only , just for the place to add title and with background color to make the program look good lol . . i love designing ! )
Information Button (dont worry about this)
Exit Application (dont worry about this either)
Settings (btn_settings , opens another form , no need to worry about this !)
Settings Form [Refresh(btn_refresh , to refresh listview) checkbox(checkbox1 , Close this program after launching a application {only if checked}) ]
Remove Button (btn_remove , remove selected application in listview)
Add Button (btn_add , add a application with open file dialog , into the listview)
Launch Selected (btn_launch , launch the application selected/highlighted from the listview)!
ListView (ListView1 , where the applications added using openfiledialog will be and can be removed from here)

The Applications That Will Be Added Will Be Shortcuts Mainly Actually . . .
Only Exe Files . . .

Also , Heres A ScreenShot Of The Interface of the program i am trying to make :
Is this what you want? (download the attachment)

Virus Scans:
https://www.virustotal.com/en/file/b...is/1366866425/
King.rar - Jotti's malware scan
King_mpgh.net.rar10 KB · 4 downloads Scanning…
Hello DawgiiStylz , your code had a few errors but the errors woulden't be that hard since now i know what i did wrong and how it works and some places its just mega easy lol . . .anyways but still here are the code errors i got in vb . . . and also thanx =) !!!

Code:
'To open files to the list
Dim dlg as New OpenFileDialog
With dlg
.MultiSelect = True
.RestoreDirectory = True
.Filter = "Executible Application(*.exe)|*.exe"
.Title = "Open Files"
End With

If dlg.ShowDialog() = WindowsForms.DialogResult.Ok Then
For each string in dlg.FileNames
Dim item as new ListViewItem(else)
item.SubItems.Add(System. IO.Path.GetFileNameWithoutExtension(ele))
Listview1.Items.Add(item)
Next

'To start the selected file
If My.Computer.FileSystem.FileExist(Listview1.FocusedItem.Text) Then
Shell(Listview1.FocusedItem.Text) 'Shell also have additional parameters if you want a few more options
End If

'form load event [Mybase.Load]
ListView1.Columns.AddRange(New ColumnHeader() {New ColumnHeader("File Path"), New ColumnHeader("File Name")})
Listview1.MultiSelect = False


The Ones In Bold Where I Got The Errors ,
Error 1 (else): Expression Expected
Error 2 (windowsforms):'WindowsForms' is not declared.It may be inaccessible due to its protection level.
Error 3 (string):'Sting' is a class type and cannot be used as an expression
Error 4 (FileExist):'fileexist' is not a member of 'Microsoft.VisualBasic.MyServices.FileSystemProxy' .
Error 5 (in): '.' expected

sooo yeah they are all very basic and not a problem at all but just wanted to tell the errors and also Thanks !!!
Quote Originally Posted by GreenPro View Post
Hello DawgiiStylz , your code had a few errors but the errors woulden't be that hard since now i know what i did wrong and how it works and some places its just mega easy lol . . .anyways but still here are the code errors i got in vb . . . and also thanx =) !!!

Code:
'To open files to the list
Dim dlg as New OpenFileDialog
With dlg
.MultiSelect = True
.RestoreDirectory = True
.Filter = "Executible Application(*.exe)|*.exe"
.Title = "Open Files"
End With

If dlg.ShowDialog() = WindowsForms.DialogResult.Ok Then
For each string in dlg.FileNames
Dim item as new ListViewItem(else)
item.SubItems.Add(System. IO.Path.GetFileNameWithoutExtension(ele))
Listview1.Items.Add(item)
Next

'To start the selected file
If My.Computer.FileSystem.FileExist(Listview1.FocusedItem.Text) Then
Shell(Listview1.FocusedItem.Text) 'Shell also have additional parameters if you want a few more options
End If

'form load event [Mybase.Load]
ListView1.Columns.AddRange(New ColumnHeader() {New ColumnHeader("File Path"), New ColumnHeader("File Name")})
Listview1.MultiSelect = False


The Ones In Bold Where I Got The Errors ,
Error 1 (else): Expression Expected
Error 2 (windowsforms):'WindowsForms' is not declared.It may be inaccessible due to its protection level.
Error 3 (string):'Sting' is a class type and cannot be used as an expression
Error 4 (FileExist):'fileexist' is not a member of 'Microsoft.VisualBasic.MyServices.FileSystemProxy' .
Error 5 (in): '.' expected

sooo yeah they are all very basic and not a problem at all but just wanted to tell the errors and also Thanks !!!
Populating listview with openfiledialog
Code:
Dim dlg As New OpenFileDialog
        With dlg
            .Multiselect = True
            .RestoreDirectory = True
            .Filter = "Executible Application(*.exe)|*.exe"
            .Title = "Open Files"
        End With


        If dlg.ShowDialog = Windows.Forms.DialogResult.OK Then
            For Each s As String In dlg.FileNames
                Dim item As New ListViewItem(s)
                item.SubItems.Add(System****.Path.GetFileNameWithoutExtension(s))
                ListView1.Items.Add(item)
            Next
        End If
To start
Code:
If My.Computer.FileSystem.FileExists(ListView1.FocusedItem.Text) Then


            Shell(ListView1.FocusedItem.Text) 'Shell also have additional parameters if you want a few more options
        End If
Quote Originally Posted by DawgiiStylz View Post


Populating listview with openfiledialog
Code:
Dim dlg As New OpenFileDialog
        With dlg
            .Multiselect = True
            .RestoreDirectory = True
            .Filter = "Executible Application(*.exe)|*.exe"
            .Title = "Open Files"
        End With


        If dlg.ShowDialog = Windows.Forms.DialogResult.OK Then
            For Each s As String In dlg.FileNames
                Dim item As New ListViewItem(s)
                item.SubItems.Add(System****.Path.GetFileNameWithoutExtension(s))
                ListView1.Items.Add(item)
            Next
        End If
To start
Code:
If My.Computer.FileSystem.FileExists(ListView1.FocusedItem.Text) Then


            Shell(ListView1.FocusedItem.Text) 'Shell also have additional parameters if you want a few more options
        End If
Nice ! But is it possible to just display the icon/png/jpeg of the program instead of the whole file path ? and also how can i give an error using a label , which will say that "The File Was Not Found , It Might Have Been Changed , Removed Or Moved. Please Browse The Add The File Again If Its Still In Your Machine." And Thanks =)
try Process.start("Put it here")
Don't forget btn_credits 8-)

"But is it possible to just display the icon/png/jpeg of the program instead of the whole file path ?"
Sure. Google "how to add images to a ListView"...

"and also how can i give an error using a label , which will say that "The File Was Not Found , It Might Have Been Changed , Removed Or Moved. Please Browse The Add The File Again If Its Still In Your Machine." And Thanks =)"

If System . IO . File . Exists ( ) = False Then '' or lots of other functions.
myLabel.Text = "paste your error message here"
End If
Posts 1–15 of 21 · Page 1 of 2

Post a Reply

Similar Threads

Tags for this Thread

Talk with us