Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: how to create and run a batch file in visual basic  (Read 10170 times)

0 Members and 1 Guest are viewing this topic.

zask

    Topic Starter


    Intermediate

    • Experience: Experienced
    • OS: Other
    how to create and run a batch file in visual basic
    « on: February 13, 2016, 09:50:40 AM »
    hello, i need a detailed explanation on how to make batch file in visual basic with visual studio, using simple commands like this

    @echo off
    title
    color 0a
    set /p "filename=Enter name of file : "
    set /p "filetext=Enter text to put in file : "
    echo %filetext% >> some %filename%.txt
    echo Created File ("%filename%").
    echo complete.
    pause

    nothing to much really, just trying to find detailed information on how to create a batch file in visual basic programming language and start it :) and it would be helpful if you could explain the vb commands... thank you

    DaveLembke



      Sage
    • Thanked: 662
    • Certifications: List
    • Computer: Specs
    • Experience: Expert
    • OS: Windows 10
    Re: how to create and run a batch file in visual basic
    « Reply #1 on: February 13, 2016, 10:03:37 AM »
    If information is static its simple just use write to file appended method but have it write to a file with .bat file extension.

    https://msdn.microsoft.com/en-us/library/1t4kyezf.aspx

    Then a system call to call to the batch file

    http://en.allexperts.com/q/Visual-Basic-1048/System-call.htm

    So from looks of it you want VB to create this batch file and then the batch file creates a text file to pass text into... Looks like homework?

    I'd give it a try on your own with info shared and post code here when you have questions or problems vs us doing all the work for you.  ;)

    Also not sure why you would be using VB to write static info and run the batch file when the batch file alone is fine by itself. The only benefit of VB for a batch file would be if your passing dynamic info to it and creating a new batch file with new info each time the VB program is run. But from your batch file, it all looks static and so the batch by itself does what you need without the VB needed to carry it out.

    zask

      Topic Starter


      Intermediate

      • Experience: Experienced
      • OS: Other
      Re: how to create and run a batch file in visual basic
      « Reply #2 on: February 13, 2016, 10:08:31 AM »
      If information is static its simple just use write to file appended method but have it write to a file with .bat file extension.

      https://msdn.microsoft.com/en-us/library/1t4kyezf.aspx

      Then a system call to call to the batch file

      http://en.allexperts.com/q/Visual-Basic-1048/System-call.htm

      So from looks of it you want VB to create this batch file and then the batch file creates a text file to pass text into... Looks like homework?

      I'd give it a try on your own with info shared and post code here when you have questions or problems vs us doing all the work for you.  ;)

      Also not sure why you would be using VB to write static info and run the batch file when the batch file alone is fine by itself. The only benefit of VB for a batch file would be if your passing dynamic info to it and creating a new batch file with new info each time the VB program is run. But from your batch file, it all looks static and so the batch by itself does what you need without the VB needed to carry it out.

      Not homework, i just need the basic command to send the text out to the batch file. thank you these links are very helpful. very appreciated! :)

      DaveLembke



        Sage
      • Thanked: 662
      • Certifications: List
      • Computer: Specs
      • Experience: Expert
      • OS: Windows 10
      Re: how to create and run a batch file in visual basic
      « Reply #3 on: February 13, 2016, 10:33:32 AM »
      No problem... VB is not my strength but I have worked with it, mostly with VB6 back in the day. C++, C#, Python, and Perl are my choice these days depending on what I am making or altering. If you have any other questions feel free to post here.

      What pushed me away from Visual Basic was that its for Windows only pretty much unless code is ported somehow. C++ and Python are my choices for cross platform programming. http://www.theregister.co.uk/2007/02/21/visual_basic_mono_linux/

      zask

        Topic Starter


        Intermediate

        • Experience: Experienced
        • OS: Other
        Re: how to create and run a batch file in visual basic
        « Reply #4 on: February 13, 2016, 11:27:28 AM »
        No problem... VB is not my strength but I have worked with it, mostly with VB6 back in the day. C++, C#, Python, and Perl are my choice these days depending on what I am making or altering. If you have any other questions feel free to post here.

        What pushed me away from Visual Basic was that its for Windows only pretty much unless code is ported somehow. C++ and Python are my choices for cross platform programming. http://www.theregister.co.uk/2007/02/21/visual_basic_mono_linux/

        Yeah i heard C# & C++
        was better but i just use visual basic because i was told it was more beginner friendly