This is under console
application. After the compilation I take the .exe
file and put it in my flash. I tried it when I specify the drive and the
location, so F:workcp.bat, works great. So I want to make it so that I
don't have to specify a drive F:, because it might not be that drive
when I plug in the USB. So maybe have it search for the drive it's
in.... (this is before I compile it... since after compilation I can't
make changes)
One more thing, what line of code should I add so that
when I run the .exe instead of the small
black window popping up, it's minimized for that ( 1 second ) it's on
the screen.
THANK YOU
Software/Hardware used: Visual Basic - under windows XP
BTW
Sub Main()
Dim shell
shell = CreateObject("wscript.shell")
shell.run(Chr(34) & ("F:workcp.bat") & Chr(34), 0)
shell = Nothing
End Sub
End Module
This is how the code looks now....
Boy, you second questions makes me wonder what your up to. Your first question has to do with the os path variable. You can't do anything about it in your program.
Well, the second question really doesn't matter... I just don't want it to keep coming up when I start the program. it's not really a big deal...
So basically I need to set the location?
The question is not clear enough.
You talk about putting your exe file in your flash drive, but the path you mention is not the path of your exe file but the path of a BAT script you execute from your program, so, how is the VB program supposed to know where you are going to put the BAT script ? Sorry, this doesn't make much sense to me.
However, if the BAT file is always going to be in the same path as the EXE file, then you don't need to specify the path:
that's what i mean... I'm just not sure how to make it find the drive... It want's me to set a drive, and I don't know what drive the USB will always be at. Could be F could be J, depends on the amount of drivers in the PC.
I don't understand this part "It want’s me to set a drive..."
What wants you to set a drive ?
Also, where is the application (exe) going to be located ?
Visual Basic. it's going to be on a flash drive, so the drivers will change. Visual basic wants me to set the specific drive F: E: etc.. but I don't know what the drive will always be...
The drive letter is inside a string, which is a parameter for the RUN command, and it is not verified at compile time.
Can you post the exact line of code you use when the drive letter is not specified, and the error message you get ?
It seems that we have a big communication problem here.
You said this: "Because if I don’t set a specific drive I can’t compile (it won’t let me compile)."
What I understand from that text is that you tried with some code without specifying the drive letter, and you got an error message. So, what is the code you tried, and what is the error message you got ?
If I understand your question correctly, you want to insert a flash drive with a program on it and you want the program to run a batch file that is on the same flash drive without knowing what the actual drive letter is going to be. If that is correct then the answer is easy: copy APP.PATH to a string variable and then get the drive letter from that:
I guess that would work, Vatchy.
My point was that if both, the application and the script (batch file), are on the same path, then there is no need to specify the path.
Free Guide: Managing storage for virtual environments
Complete a brief survey to get a complimentary 70-page whitepaper featuring the best methods and solutions for your virtual environment, as well as hypervisor-specific management advice from TechTarget experts. Don’t miss out on this exclusive content!
Discuss This Question: 16  Replies