create and execute bat file in vb.net

Discussion in 'ASP .Net' started by Eric Wood, Nov 5, 2003.

  1. Eric Wood

    Eric Wood Guest

    We have an application that is accessed using shared drives, client
    executes program from server. We have already coded the program to
    create and save the a bat file either locally on the users machine or
    on the
    server. Our problem is that when we execute the bat file from the
    vb code it does not work properly. The bat file is used to connect to
    a commnad line service running on the server and update a file in
    another system. We can execute the bat properly from our local drives
    as well from the server if we use pc anywhere and the system is
    updated. If we execute it from within the vb code it fails, we see the
    command window come up but the update does not happen. In order to run
    properly the bat must be in the same directory as a client executable
    and a mapping file I am wondering if when running it from within the
    client code we are disassocating it from these. The code we are using
    to create and execute the bat is as followd.

    Dim strMacNo As String = txtField8.Text

    Dim strHelpDeskNo As String = txtField5.Text

    Dim strMessage As String = txtField11.Text

    Dim srw As StreamWriter = File.CreateText(FILE_NAME)

    srw.WriteLine("REM :START")

    srw.WriteLine("client AddCallNote.txt ResultsFile.xml uid pwd " &
    strHelpDeskNo & " ADMIN MOVE_TEAM PROGRESS_UPDATE " & """" &
    strMessage & """" & " " & """" & strMacNo & """")

    srw.WriteLine("REM GOTO START")

    srw.Close()

    Dim p As Process = New Process

    Dim s As String

    Dim outfile As String = Application.StartupPath & FILE_NAME

    Dim sysFolder As String =
    System.Environment.GetFolderPath(Environment.SpecialFolder.System.System)



    p.StartInfo.FileName = "cmd.exe"

    p.StartInfo.Arguments = "/C cd " & _

    sysFolder & " && dir *.com >> " & Chr(34) & _

    outfile & Chr(34) & " && exit"

    p.StartInfo.WindowStyle = ProcessWindowStyle.Maximized

    p.StartInfo.CreateNoWindow = False

    p.Start()


    any ideas?
     
    Eric Wood, Nov 5, 2003
    #1
    1. Advertising

  2. Eric Wood

    natewcu

    Joined:
    Jun 26, 2007
    Messages:
    1
    Have you had any luck resovling you issue? i'm having the same problems. I can shell my bat file correctly from a windows application but not from a service. It is very frustrating.
     
    natewcu, Jun 26, 2007
    #2
    1. Advertising

  3. Eric Wood

    shamirza

    Joined:
    Jul 10, 2007
    Messages:
    2
    guess!! check security and privillage part.

    guess!! check security and privillage part it may resolve. the issue is definately related to it. nothing to do with any logic looks.

    Thanks
    Sha Mirza
    www.shamirza.cjb.net
     
    shamirza, Jul 10, 2007
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. wschrap
    Replies:
    2
    Views:
    4,203
    imransyed63
    Jul 28, 2006
  2. Bianca
    Replies:
    0
    Views:
    486
    Bianca
    Jun 19, 2011
  3. Rocket Hawk

    error execute bat file from asp

    Rocket Hawk, Jan 12, 2004, in forum: ASP General
    Replies:
    4
    Views:
    166
    Rocket Hawk
    Jan 12, 2004
  4. Sojwal

    Can't execute WSH script from bat file

    Sojwal, Aug 13, 2004, in forum: ASP General
    Replies:
    0
    Views:
    101
    Sojwal
    Aug 13, 2004
  5. Tom Salzmann
    Replies:
    3
    Views:
    262
Loading...

Share This Page