Visual Basic Running external .exe issue - vb.net

I am currently working on a project and have found that using the Process.Start and shell commands to run other existing programs is being problematic. What happens is that when I click the button in my program to launch the other exe file it loads the program but not correctly, iv seen this behavior in two external programs of mine one fails to update when run through my program but on its own works fine the other fails to load up the interface correctly and gives me an error.
The error tells me it cant find the resources it relies on to function so can anyone tell me why it does this and a possible solution as iv tried all the startup codes I know: Start, Process.Start and shell?
EDIT
I also found that if I place my exe in the same folder as the program I want to run it works fine but this is not suitable for my project so any workarounds?
Solution:
Thanks for all your help I needed to set the working directory, beginners mistake :)
Dim filePath As String = "C:\Program Files\Example\Example.exe"
Dim psi As New ProcessStartInfo(filePath)
psi.WorkingDirectory = IO.Path.GetDirectoryName(filePath) Process.Start(psi)

You have to define a WorkingDirectory
var proc = new System.Diagnostics.Process();
proc.StartInfo.WorkingDirectory = "The Location of the process";
proc.Start("the process");

Related

How do I get my neovim settings to work properly and actually save

I just installed nvim for the first time, this is also my first time using a terminal based code editor, and I'm migrating from VSCode (ik it's going to be hard),
and now I'm configuring it, I'm following this tutorial:
https://www.youtube.com/watch?v=vdn_pKJUda8&t=347s&ab_channel=JoseanMartinez
And when put the code in the options.lua file, it does not do anything, for example, the
opt.relativenumber = true
is not doing anything
I have tried running commands to change settings, and that has worked, for example
:set relativenumber
But as soon as I exit the file and open a new one, it just breaks again
I have tried simply copy and pasting the code, restarting nvim, switching terminal emulators, etc.
It's really annoying because I am trying to get rid of this stupid feature where it continues comments to the next line and I have to run like 50 commands every time I open a new file just so I can edit it the way I want
My .config file is in
C:\Users\brady\.config
and my nvim.exe file is in
C:\Users\brady\nvim-win64\bin
I am on Windows 10 and my terminal emulator is called 'Tabby'
I figured it out! All the tutorials I am watching are on Linux, but I am on Windows. So instead of putting the nvim folder in my .config, I am supposed to put it in C:\Users\brady\AppData\Local
Are you sure that you're adding your nvim-config file in the correct directory? I'd assume that you need to add your init.vim into C:\Users\brady\.config\nvim\init.vim.
Maybe this answer helps you.

VB.net Open OneNote with command line switches

anyone know best way to open OneNote with supporting command line switches?
For example:
Process.Start("OneNote.exe", "/nologo")
This just opens OneNote and still shows the splash screen. Any ideas?
Thanks in advance.
The way you are doing it now is correct to say. One thing to mention though is the version of OneNote you are using, I believe that only works for 2007 and nothing newer.
You have a few option's to start OneNote with line switches. You can either use the Process.Start or ProcessStartInfo to accomplish this. Please see example's below.
This is straight to the point and will work (depending on the version of OneNote)
Process.Start("OneNote.exe", "/nologo")
Another option to use is ProcessStartInfo (same concept as above, but broken out). I used /paste to confirm this and it pasted what I had in the ClipBoard to OneNote
'Create the new StartInfo
Dim prsi As New ProcessStartInfo("OneNote.exe")
prsi.Arguments = "/paste"
'Start the actual process
Process.Start(prsi)
To view more command line switches you can look https://support.office.com/en-in/article/Command-line-switches-in-Microsoft-Office-OneNote-2007-29468957-1fcc-48b8-8821-00fe5518493a there.
Make it with Dim proc as new system.diagnostics.process
And then use proc.startinfo.arguments = "/nologo"
Do not use quotes around the switch.
Use quotes only around the executable.
Like this:
Process.Start("OneNote.exe", /nologo)
Now, let me add here that a soap dish probably has more knowledge about VB.net than me. So as far as the rest of the call (comma, spacing, etc), I'll trust you've got that nailed. ;)

How to integrate an exe file and 2 dll files into my visual basic program?

I am writing a visual basic GUI program with a form. Now my program makes use of an executable(command line program) file called adb.exe. This file depends on 2 dll files. I want to integrate these 3 files into my program so that I can execute commands from the adb.exe file. How can I do this? I need just the integration part. I know how to execution of commands part. I tried putting the 3 files into my project in visual studio but it doesn't work.
Add them as resources, and set them as embedded resources.
When you need them you can extract them with a similar code:
Dim Resourcename() As Byte = My.Resources.yourresourcename
Dim FileN As New System.IO.FileStream("path to the wished location and filename", System.IO.FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite)
Dim BW As New System.IO.BinaryWriter(FileN)
BW.write(Resourcename)
BW.Close()
FileN.Close()
Add them to your application's resources
Under the project tab, select properties.
From the properties menu, select the reference tab, and set 'copy local' to true for all of them.
Now 'publish' the program and all the references will be included with the build and referenced correctly.

Exception trying to Start a process after copying the file

I'm getting an annoying error like:
The process cannot access the file 'C:\Program Files (x86)\AceHc\trfpt.exe' because it is being used by another process.
The error happens when I try to use Process.Start after File.Copy the same file.
Code:
File.Copy(PathFrom & "\trfpt.exe", PathTo & "\trfpt.exe", True)
Process.Start(PathTo & "\trfpt.exe")
What am I doing wrong?
Do you have a virus scanner that might be scanning the file directly after the copy and blocking it?
It might be worth trying to temporarily disable it and see if the problem goes away.
Also, depending in the size of the file, maybe the EXE file is still being copied (that is, the copy function doesn't block que program flow, your code continue and the copy process continue in background).
Download Handle from Windows Sysinternals and run it as admin from cmd to get a list of processes which hold a handle on that file:
handle.exe trfpt.exe
A wild guess - do you have a Windows Explorer window open looking at the folder 'Pathto' ?

system.diagnostic.process.start problem

Im trying to create an application launcher using vb.net. I'm trying to launch desktop shortcuts that are hidden because I want my desktop to be free of mess. Those shortcuts are created through nircmd :http://www.nirsoft.net/utils/nircmd.html
I used this code:
System.Diagnostics.Process.Start("E:\Documents and Settings\Rew\Desktop\SpeakClipboard.exe")
And it returned the error that the path specified cannot be found.
I tried launching an application in program files using this method and it worked well.
Is there a problem with shortcuts? I cannot specify the path for the file where the shortcut is linked because its a shortcut in the desktop and doesn't point to anything except the nircmd.exe that is on : F:\NIRCMD
But I also tried using this path for system.diagnostic.process.start:
F:\NIRCMD\nircmd.exe cdrom open g:
But still no luck.
If I understand correctly SpeakClipboard.exe is actually a shortcut? If so it probably has a hidden .lnk extension. So you should specify SpeakClipboard.exe.lnk or SpeakClipboard.lnk if it doesn't actually have .exe in the name.
There is a property on the ProcessStartInfo object that allows you to specify an argument.
eg your command would be "F:\NIRCMD\nircmd.exe" and the arguments would be "cdrom open g:"
Does that work?