VB.net Launcher Application Error - vb.net

i've been created launcher application with vb.net, but when the target application began, there was an error "Can not Read Start.ini file".
I tried with this code
Dim psi As New ProcessStartInfo()
With psi
.FileName = sb.ToString
.UseShellExecute = True
End With
Process.Start(psi)
how to fix it ?

Daniel probably has it right. Try setting the WorkingDirectory property based off your FileName:
Dim psi As New ProcessStartInfo()
With psi
.FileName = sb.ToString
.WorkingDirectory = System.IO.Path.GetDirectoryName(.FileName)
.UseShellExecute = True
End With
Process.Start(psi)

Related

Print PDF file with printdialog vb.net

I'm trying to print a external pdf file with printdialog options but the file is printed with predeterminated printer config
Dim result As DialogResult = PrintDialog1.ShowDialog()
If (result = DialogResult.OK) Then
Dim psi As New ProcessStartInfo
psi.UseShellExecute = True
psi.Verb = "print"
psi.WindowStyle = ProcessWindowStyle.Hidden
psi.Arguments = PrintDialog1.PrinterSettings.PrinterName.ToString()
psi.FileName = "file.pdf"
Process.Start(psi)
End If
You would need to use the "PrintTo" verb rather than the "Print" verb. You would also need to wrap the printer name in quotes if it might have spaces in it. I would suggest making your code a bit more succinct:
Process.Start(New ProcessStartInfo("file.pdf",
$"""{PrintDialog1.PrinterSettings.PrinterName}""") With {.Verb = "printto",
.UseShellExecute = True,
.WindowStyle = ProcessWindowStyle.Hidden})

standard outputread does not read anything until process is closed vb.net

I am trying to redirect the output from xfoil.exe with downloadables here. The issue is when I am redirecting the standardoutput, my code will not read anything until I use the "quit" command which closes the external xfoil.exe and hence, I cannot run any further commands.
first defining variables
Dim p as process = New Process()
Dim startinfo = New ProcessStartInfo()
Dim bt As Threading.Thread
I start the process using
With startinfo
.FileName = Application.StartupPath & "\appdata\xfoil.exe"
.Arguments = ""
.WorkingDirectory = Application.StartupPath
.RedirectStandardError = True
.RedirectStandardOutput = True
.RedirectStandardInput = True
.UseShellExecute = False
.CreateNoWindow = True
End With
p.StartInfo = startinfo
p.EnableRaisingEvents = True
If Not IsNothing(bt) Then bt.Abort()
bt = New Threading.Thread(AddressOf ReadThread)
bt.IsBackground = True
bt.Start()
p.Start()
The definition for the ReadThread is
Private Sub ReadThread()
Dim rLine As String
Do Until Leaving
Try
rLine = p.StandardOutput.Read()
logtext += (Chr(rLine))
If p.StandardOutput.Peek = -1 Then
Me.Invoke(Sub() txtLog.AppendText(logtext))
logtext = ""
End If
Catch ex As Exception
Console.WriteLine("error " & ex.Message)
End Try
Loop
End Sub
This setup works perfectly with another app from the same developer Mark Drela. When I use the other app AVL with download link here everything works fine. However, xfoil does not work with this setup and I have spent some hours on this without any luck. I am using VB.net on Windows 10 in Visual Studio.NET 2019 community edition.
Edit
Both methods using threading and events were implemented and no luck.
A sample code using both methods in VB.net is now available on Github for review comments. Let me know if anyone has any experience with this and can help. This would really help my students in the class!

How to start outlook minimized (vb.net)

Following code starts excel minimized.
Dim psi As New ProcessStartInfo("excel.exe")
psi.WindowStyle = ProcessWindowStyle.Minimized
Process.Start(psi)
Following code starts notepad minimized.
Dim psi As New ProcessStartInfo("notepad.exe")
psi.WindowStyle = ProcessWindowStyle.Minimized
Process.Start(psi)
Following code does not start outlook minimized.
Dim psi As New ProcessStartInfo("outlook.exe")
psi.WindowStyle = ProcessWindowStyle.Minimized
Process.Start(psi)
Why?
Related link: (C#)
How to start Outlook minimized?

Need to prompt user for UAC when attempting to open a share using Process.Start

This works, if the current user has rights to the UNC path. Opens it right up.
Process.Start("\\USERSHARE\VALUE\EMPLOYEES\")
However, I have to run the entire program as a user that doesn't have access to the UNC path due to SQL permissions in the code.
I made a button in the app that will open the UNC path in an explorer window, but I cannot figure out how to force a runas for the operation.
I have tried the following as well:
Dim procStartInfo As New ProcessStartInfo
Dim procExecuting As New Process
With procStartInfo
.UseShellExecute = True
.FileName = "Notepad.exe"
.WindowStyle = ProcessWindowStyle.Normal
.Verb = "runas" 'add this to prompt for elevation
End With
procExecuting = Process.Start(procStartInfo)
This works and prompts with UAC to open "notepad".
This doesn't work to open the UNC path:
Dim procStartInfo As New ProcessStartInfo
With procStartInfo
.UseShellExecute = True
.FileName = "\\USERSHARE\VALUE\EMPLOYEES\"
.WindowStyle = ProcessWindowStyle.Normal
.Verb = "runas" 'add this to prompt for elevation
End With
Process.Start(procStartInfo)
I understand opening the fileshare isn't the same as pointing the .FileName at an executable.
I'm having problems trying to have the app prompt for UAC before attempting to open the remote folder.
You don't want to execute the folder itself, but rather explorer.exe with the folder as an argument:
Dim procStartInfo As New ProcessStartInfo
With procStartInfo
.UseShellExecute = True
.FileName = "explorer.exe"
.Arguments = "\\USERSHARE\VALUE\EMPLOYEES\"
.WindowStyle = ProcessWindowStyle.Normal
.Verb = "runas" 'add this to prompt for elevation
End With
Process.Start(procStartInfo)

Run CMD Silently

I'm trying to run CMD silently, but each time I get an error. Could someone please tell me where I'm going wrong?
Dim myProcess As Process
myProcess.StartInfo.WindowStyle = ProcessWindowStyle.Hidden
myProcess.StartInfo.CreateNoWindow = True
myProcess.StartInfo.FileName = ("cmd.exe" & CmdStr)
myProcess.Start()
CmdStr is already a string to do certain things that I want in the application.
I suppose your cmdStr is a string with parameters for CMD.
If so you need to use the Arguments property of StartInfo.
You get a Null Exception on the myProcess variable because it is never instatiated with new.
You could create a ProcessStartInfo var to use with the static Process.Start method and set the UseShellExecute to False
Dim startInfo As New ProcessStartInfo("CMD.EXE")
startInfo.WindowStyle = ProcessWindowStyle.Hidden
startInfo.CreateNoWindow = True
startInfo.UseShellExecute = False
startInfo.Arguments = CmdStr
Process.Start(startInfo)
or edit your code to add
myProcess = new Process()
before using the var myProcess