including a file in my exe

bobbel

New member
Joined
Nov 3, 2008
Messages
3
Programming Experience
1-3
hello everybody!

i have a problem. What i want is that i can include a file (a bat or something) and that i can say in my code Shell("clean.bat") without that file being in the same folder as my exe. How do i do that?:confused:
 
You can use
shell("C:\folder\clean.bat")
or if the bat file is in the same folder as your exe use
shell(Application.StartupPath() & "\clean.bat")
 
what i want is to embed the file in my exe and that i can execute my .bat with shell("clean.bat") anybody know? nvm, did it otherwise
 
Last edited:
Before you can run a file like that you need to make a copy of it outside your exe file, you can use a FileStream to copy it out of the resources, then run it using Process.Start("Path to file")
 
well, what i did: when you press a button, it print a bat file that ends with "del clean.bat" and then executes it, so you can't read it and you nearly can't copy it
 
Sorry if my guess is wrong. Judging by the name of your bat file. If you are deleting all files in a folder then you can use this.
VB.NET:
For Each foundFolder As String In My.Computer.FileSystem.GetDirectories("C:\Test")
            My.Computer.FileSystem.DeleteDirectory(foundFolder, FileIO.DeleteDirectoryOption.DeleteAllContents)
        Next
For Each foundFile As String In My.Computer.FileSystem.GetFiles( "C:\Test", FileIO.SearchOption.SearchAllSubDirectories, "*.*")
            My.Computer.FileSystem.DeleteFile(foundFile, FileIO.UIOption.OnlyErrorDialogs, FileIO.RecycleOption.DeletePermanently)
        Next
I modified the code from here.
 
Last edited:
well, what i did: when you press a button, it print a bat file that ends with "del clean.bat" and then executes it, so you can't read it and you nearly can't copy it


If you really want a batch file... and it must be part of the exe..

My work around would be to create a sub routine which actually creates a new batch file and writes the content to it.

Then run the file and after the execution has completed, delete it.
 
Back
Top