Skip to content
View in the app

A better way to browse. Learn more.

MSFN

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

VB 2008: Open textfile and use the file to run an exe file

Featured Replies

I am a beginner using VS 2008. I am trying to use VB to create a window form whereby user will open a few files to run with an exe file.

I have a python code which already converted to an exe-readable file. In order to run the exe file, i still need to fetch input arguments (in this case, some text files) to execute the exe program.

Over at VS, i am creating a window form where there is an open button to allow user to search for the files (txt files) they wish to fetch - this will show in the textbox, and using the files they chose, user will click on the 'Execute' button to run the program.

I managed to find the cmd code to run an exe file, however i am not sure how i can place my txt files to run together with my exe program.

Can anyone able to help me ??

Cheers

  • Author

I am a beginner using VS 2008. I am trying to use VB to create a window form whereby user will open a few files to run with an exe file.

I have a python code which already converted to an exe-readable file. In order to run the exe file, i still need to fetch input arguments (in this case, some text files) to execute the exe program.

Over at VS, i am creating a window form where there is an open button to allow user to search for the files (txt files) they wish to fetch - this will show in the textbox, and using the files they chose, user will click on the 'Execute' button to run the program.

I managed to find the cmd code to run an exe file, however i am not sure how i can place my txt files to run together with my exe program.

Can anyone able to help me ??

Cheers

I managed to find a script by doing some searches:

Shell "C:\Path\MyExe.exe this_is_the_cmd_line"

and apparently it's worked as commented by the user.

As the parameter i am using might come from a different file location and it can be more than 1 file. How am i suppose to do sO?

Use variables for the switches, you could use one for the executable also if needed.

Note Syntax my not be exactly correct (too many languages in my head and I don't have VS installed at the moment)

My_Prog = "C:\path\myexe.exe"

...

myParam=replace(ParamTextbox.text, chr(13), " ") ' replaces carriage returns with spaces

Shell My_prog myParam

  • Author

hi,

it doesnt seem to work.

For example i have a textbox which will display the files location using OpenFileDialog1(open_click_button). Inside this textbox, it might display more than 1 file from a certain directory.

After which, i would like to use this files from this directory to act as a parameter into an exe file.


Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim strFileName As String
OpenFD.InitialDirectory = "C:\"

OpenFD.Title = "Open a Summary File"
OpenFD.Filter = "Summary Files|*.summary"
Dim DidWork As Integer = OpenFD.ShowDialog()
If DidWork = DialogResult.Cancel Then
Else
strFileName = OpenFD.FileName

TextBox1.AppendText(strFileName)
TextBox1.AppendText(" ")
End If
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim ChosenPlatform As String
Dim MyProg As String
'Dim filename1 As String
Dim myParam As String

If RadioButton1.Checked = True Then
ChosenPlatform = RadioButton1.Text
MyProg = "C:\My Documents\Visual Studio 2008\Projects\Project1\summary\sum_trial1\sum_trial1\program1.exe"
'filename1 = "text.txt"

myParam = Replace(TextBox1.Text, Chr(13), " ") ' replaces carriage returns with spaces
System.Diagnostics.Process.Start(MyProg, myParam)
TextBox1.Text = " "
ElseIf RadioButton2.Checked = True Then
ChosenPlatform = RadioButton2.Text

ElseIf RadioButton3.Checked = True Then
ChosenPlatform = RadioButton3.Text

End If
'MsgBox("You select " & ChosenPlatform & " platform. Report will be saved in C:\MY DOCUMENT and current folder")

End Sub








If you popup a msgbox (or setup a watch and step through the program) after the myParam line do you get what you need to run it? if there are spaces in the parameters does the program require they be surrounded by quotes?

   	myParam = Replace(TextBox1.Text, Chr(13), " ") ' replaces carriage returns with spaces
System.Diagnostics.Process.Start(MyProg, myParam)

  • Author

Yes, when i popup a msgbox, the location of the file chosen is correct.. However, I am wondering when i executed

System.Diagnostics.Process.Start(MyProg, myParam)

, can the .exe be able to capture the parameter from "myParam" ?

that is:

under the MS-Dos command, i'll enter

C:\Python26>test.exe file1.txt file2.txt file3.txt

from above:

if MyProg = test.exe

then myParam = file1.txt file2.txt file3.txt

But when i run this script, myParam = C:/desktop/file1.txt ---> therefore when i started to execute the

System.Diagnostics.Process.Start(MyProg, myParam)

the script will be reading as

test.exe C:/desktop/file1.txt C:/desktop/file2.txt C:/desktop/file3.txt

??

Create an account or sign in to comment

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.