Results 1 to 5 of 5

Thread: [RESOLVED] [02/03] creating a batch file

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Oct 2006
    Posts
    25

    Resolved [RESOLVED] [02/03] creating a batch file

    i want to create a batch file and then using it i want to execute a few commands...........

    when we type commands in notepad and save it as .bat how can be pass vaiables from the vb.net program to teh bat file..
    or can we create a batch file from the program itself....

  2. #2
    PowerPoster sparrow1's Avatar
    Join Date
    May 2005
    Location
    Globetrotter
    Posts
    2,820

    Re: [02/03] creating a batch file

    Quote Originally Posted by suba_shania
    i want to create a batch file and then using it i want to execute a few commands...........

    when we type commands in notepad and save it as .bat how can be pass vaiables from the vb.net program to teh bat file..
    or can we create a batch file from the program itself....
    Hi,

    Here's a link how to create a Batch File;

    http://msdn2.microsoft.com/zh-cn/library/ms181076.aspx

    Hope it helps,

    sparrow1
    Wkr,
    sparrow1

    If I helped you, don't forget to Rate my post. Thank you

    I'm using Visual Studio.Net 2003 and
    2005
    How to learn VB.Net Create setup with VB 2005 Drawing for beginners VB.Net Tutorials GDI+ Tutorials
    Video's for beginners

  3. #3
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: [02/03] creating a batch file

    Here is one way.
    VB Code:
    1. Dim sr As New StreamWriter("C:\Test.bat")
    2. sr.WriteLine("@echo ""Hello World""")
    3. sr.WriteLine("pause")
    4. sr.Close()
    5. System.Diagnostics.Process.Start("C:\Test.bat")
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [02/03] creating a batch file

    A batch file is just a text file that contains commandline instructions. You can create a text file easily enough in VB.NET. If you want to execute a batch file, either pre-existing or one you've just created yourself, then you do so the same way as you execute any other file:
    VB Code:
    1. Process.Start("file path here")
    If you want to pass commandline arguments to that batch file, again, you do so the same way as you would for any other file being executed:
    VB Code:
    1. Process.Start("file path here", "commandline arguments here")
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Oct 2006
    Posts
    25

    Re: [02/03] creating a batch file

    thx ppl using steamwriter i created a batch file

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width