CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Sep 2010
    Posts
    1

    Question WScript.Shell Run

    Heya,

    I have the following codeing in a .vbs file.

    Set WshShell = CreateObject("WScript.Shell")

    WshShell.Run chr(34) & "C:\Test.exe" & Chr(34), 0

    Set WshShell = Nothing

    Running this code excutes the test.exe hiding the promopt but without 3 paramters the exe fails. Normally this could be passed by a .bat or shortcut such as

    Shortcut "C:\Test.exe" 10 1024 1024

    Bat Start C:\Test.exe 10 1024 1024.

    Could anyone tell me how i could put these 3 numbers into the vbs coding so my .exe will work.

  2. #2
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: vbscript WshShell.Run Parameter

    If you want to hard-code, it's easy. Otherwise, use your program to WRITE a Batch File, then execute it.

    Code:
    Set WshShell = CreateObject("WScript.Shell")
    
    WshShell.Run chr(34) & "C:\Test.exe  1 2 3" & Chr(34), 0
    
    Set WshShell = Nothing
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  3. #3
    Join Date
    May 2002
    Posts
    10,943

    Re: WScript.Shell Run

    [ split thread ]
    If the post was helpful...Rate it! Remember to use [code] or [php] tags.

  4. #4
    Join Date
    Apr 2009
    Posts
    598

    Re: WScript.Shell Run

    You can give arguments to your VBS file and pass them to test.exe:
    Code:
    Set WshShell = CreateObject("WScript.Shell") 
    
    WshShell.Run chr(34) & "C:\Test.exe " & WScript.Arguments.Item(0) & " " & WScript.Arguments.Item(1)  & " " & WScript.Arguments.Item(2) & Chr(34), 0
    
    Set WshShell = Nothing

  5. #5
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: WScript.Shell Run

    That doesn't say how to use them.
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

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

Featured