Running Batch File With O/P Redirection From VB


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 6 of 6

Thread: Running Batch File With O/P Redirection From VB

  1. #1
    Join Date
    Jul 2008
    Posts
    2

    Post Running Batch File With O/P Redirection From VB

    Hi,
    I have a batch file which does a o/p redirection like the following :
    Code:
    @echo off
    :BEGIN
    cls
    rsh <ip> -l <username> "if ps -efW | grep \"abcd\" >/dev/null 2>/dev/null; then echo 1 ; else echo 0 ; fi;" > file_already_running
    for /f %%a in (file_already_running) do (
    if %%a==1 (
    echo 0 > error_level
    ) else ( 
    echo 1 > error_level
    rsh <ip> -l <username> -n "cd c:/dd/; ./abcd.exe -t \"101\" -i \"abcd.ini\" >/dev/null 2>/dev/null </dev/null &"
    )
    exit /b
    )
    :End
    I have a VB code which call the above batch file :
    Code:
    Private Sub Command1_Click()
    Dim ret As String
    Dim strCommand As String
    Dim val_error As Integer
    ret = Shell("c:/sample.bat", vbHide)
    While I am running the bat file directly from dos prompt, the files file_already_running and error_level are created properly, but while calling it from VB, these two files are not created.

    Please help.

    -SukumarM

  2. #2
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,663
    Welcome to DevX

    Does VB produce any errors when you Shell the .bat file?

  3. #3
    Join Date
    Aug 2004
    Location
    Orange, California
    Posts
    1,263
    Also shouldn't it be c:\ not c:/

  4. #4
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,663
    Quote Originally Posted by Ron Weller
    Also shouldn't it be c:\ not c:/
    Good eyes.....I didn't catch that the first time.

  5. #5
    Join Date
    Jul 2008
    Posts
    2
    Thanks for the replies.
    Actually, the files were created in VB's app directory instead of the path defined in batch file. I provided absolute path in batch file and it worked.
    Thanks again.

    -Sukumar

  6. #6
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,663
    Hard coding the path will not pose a problem in the future?

Similar Threads

  1. Typical File open, file save, etc in VB
    By Athono in forum VB Classic
    Replies: 1
    Last Post: 12-19-2005, 07:58 PM
  2. Please help with running executable vb program.
    By Gordon Reichhardt in forum VB Classic
    Replies: 2
    Last Post: 01-08-2002, 11:06 AM
  3. writing & Generating a log file in vb
    By Rajiv in forum VB Classic
    Replies: 1
    Last Post: 09-21-2001, 10:18 AM
  4. .bat file exuted from VB
    By David in forum VB Classic
    Replies: 1
    Last Post: 09-04-2001, 08:38 AM
  5. Replies: 0
    Last Post: 01-05-2001, 03:18 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center