Results 1 to 6 of 6

Thread: [RESOLVED] Command shel Help for VB studio[2005] I HOPE ITS POSSIBLE!!!!!!!!!!!!!

  1. #1

    Thread Starter
    Hyperactive Member g4hsean's Avatar
    Join Date
    May 2006
    Posts
    267

    Resolved [RESOLVED] Command shel Help for VB studio[2005] I HOPE ITS POSSIBLE!!!!!!!!!!!!!

    Hi, I'm fairly new to vb 2005 but am very good with vb6... so my main question is how do I send dos commands to the computer without having the user open any command prompts. SO example I would like to execute this command from my program...

    EX: C:\>IpConfig



    and of course all the output would be shown... This program will be only to show your ip and other dos command tasks. It has to be dos and no other method PLEASE. I need it to be able to communicate with dos like a command prompt. Thanks for viewing my post and hope any of you experts could help me out with this tricky yet fun task.
    Coding's a Breeze if you'r at ease! GOD THATS CORNY!!
    -

  2. #2
    Lively Member
    Join Date
    Feb 2007
    Location
    Toronto, ON
    Posts
    117

    Re: Command shel Help for VB studio[2005] I HOPE ITS POSSIBLE!!!!!!!!!!!!!

    well....you can still use Shell(stringCommand) like before...but as far as actually showing the result, i'm not sure.

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

    Re: Command shel Help for VB studio[2005] I HOPE ITS POSSIBLE!!!!!!!!!!!!!

    Depending on the amount of control, you could use ProcessStartInfo to execute a command prompt window passing the dos arguments.

    The /C means to close the command window when complete. /K would mean to keep it open.

    vb Code:
    1. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    2.     Dim oPSI As New System.Diagnostics.ProcessStartInfo
    3.     With oPSI
    4.         .FileName = "C:\Windows\System32\cmd.exe"
    5.         .CreateNoWindow = True
    6.         .WindowStyle = ProcessWindowStyle.Hidden
    7.         .WorkingDirectory = "C:\Users\VB-Guru\"
    8.         .UseShellExecute = True
    9.         .Arguments = "/C Ping google.com > PingResults.txt"
    10.     End With
    11.     System.Diagnostics.Process.Start(oPSI)
    12. End Sub
    Last edited by RobDog888; Mar 28th, 2007 at 08:13 PM.
    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

    Thread Starter
    Hyperactive Member g4hsean's Avatar
    Join Date
    May 2006
    Posts
    267

    Re: Command shel Help for VB studio[2005] I HOPE ITS POSSIBLE!!!!!!!!!!!!!

    Thank you verry much for the quick responce time.... RobDog888 your code did exactly what i was looking for and thank you very much.
    Coding's a Breeze if you'r at ease! GOD THATS CORNY!!
    -

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

    Re: Command shel Help for VB studio[2005] I HOPE ITS POSSIBLE!!!!!!!!!!!!!

    No prob. Glad to help.

    I added an enhancement for opening the textfile (optional) when its done processing.

    vb Code:
    1. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    2.     Dim oPSI As New System.Diagnostics.ProcessStartInfo
    3.     Dim oProcess As System.Diagnostics.Process
    4.     With oPSI
    5.         .FileName = "C:\Windows\System32\cmd.exe"
    6.         .CreateNoWindow = True
    7.         .WindowStyle = ProcessWindowStyle.Hidden
    8.         .WorkingDirectory = "C:\Users\VB-Guru\"
    9.         .UseShellExecute = True
    10.         .Arguments = "/C Ping google.com > PingResults.txt"
    11.     End With
    12.     oProcess = System.Diagnostics.Process.Start(oPSI)
    13.     oProcess.WaitForExit()
    14.     System.Diagnostics.Process.Start(oPSI.WorkingDirectory & "PingResults.txt")
    15. End Sub
    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

  6. #6

    Thread Starter
    Hyperactive Member g4hsean's Avatar
    Join Date
    May 2006
    Posts
    267

    Re: Command shel Help for VB studio[2005] I HOPE ITS POSSIBLE!!!!!!!!!!!!!

    thanks :P
    Coding's a Breeze if you'r at ease! GOD THATS CORNY!!
    -

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