Visual Studio call embedded bat file

Posted on 2011-10-11
Medium Priority
Last Modified: 2012-05-12
I have a Visual Studio 2010 program that has an embedded .bat, .xml and .exe used to setup a wireless network. If I place the .bat, .exe and .xml in the running directory of the complied program, and use System.Diagnostics.Process.Start("xxx.bat"), the bat correctly calls the exe and xml files and configures the wireless network. Now no matter what I do I can not get it to call the embedded bat file.

Any help would be greatly appreciated
Question by:schmittg25
  • 2
LVL 83

Accepted Solution

CodeCruiser earned 2000 total points
ID: 36951688
The embedded file is only visible to your program not Windows. You need to write this file to disk somewhere and then execute it.

Author Comment

ID: 36951958
oh.... how could I do that?
LVL 83

Expert Comment

ID: 36952052
You can read the embeded file as stream and then write that stream to disk

Use the following function

Public Function ExtractResourceToDisk(ByVal ResourceName As String, ByVal FileToExtractTo As String) As Boolean

    Dim s As System.IO.Stream = System.Reflection.Assembly.GetExecutingAssembly.GetManifestResourceStream(ResourceName)
    Dim ResourceFile As New System.IO.FileStream(FileToExtractTo, IO.FileMode.Create)

    Dim b(s.Length) As Byte

    s.Read(b, 0, s.Length)
    ResourceFile.Write(b, 0, b.Length - 1)

    ResourceFile = Nothing
End Function

Open in new window


Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses
Course of the Month13 days, 22 hours left to enroll

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question