473,325 Members | 2,342 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

create and execute bat file in vb.net

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.Speci alFolder.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?
Nov 20 '05 #1
1 14565
Perhaps try setting the working directory of the StartInfo to
directory in which the executed batch file resides.

Otherwise I think it defaults to the application directory and that
would fail if the batch is trying to access anything using a relative
and not absolute path.

---
Regards,

Roy Osherove
www.iserializable.com
On 5 Nov 2003 12:35:20 -0800, er*******@us.icap.com (Eric Wood) wrote:
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.Spec ialFolder.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?


Nov 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Lauren Quantrell | last post by:
Is there a way to create a text file (such as a Windows Notepad file) by using a trigger on a table? What I want to do is to send a row of information to a table where the table: tblFileData has...
22
by: nobody | last post by:
hello everybody, is there a way of creating an array with help of a function that would accept the name of this array as a parameter and then create global Array type variable of that name? so...
9
by: Albretch | last post by:
.. I am trying to create a database in a MS Access DB via JDBC drivers. I have tried both sun.jdbc.odbc.JdbcOdbcDriver and ids.sql.IDSDriver From some reason both drivers Exceptions tell me...
2
by: Mikey | last post by:
Sample VB .NET source code to create mailing labels or customized letters using MS Word MailMerge This VB .NET source code will start MS Word and call methods and set properties in MS Word to...
7
by: Roemer | last post by:
Hi all I stumbled over a new problem: I have a programm with just a class that is asynchronous listening for network connections. As soon as someone connected, a new form needs to be created....
2
by: Michael | last post by:
Hello, I've created an ASP web page where users in our organization can create Active Directory computer accounts. The web page is running on a Server 2003 SP1 IIS 6 installation. The...
2
by: tanyali | last post by:
I am using Linux Suse10, php 5 . execute a shell script in a terminal, it works. output is a file with data . when I use it in php like this (code : php) : chdir("../file");...
1
by: henrymania | last post by:
Am writing a code for database backup....by backupservlet is as given below i get the following exception
0
by: kurtf | last post by:
Hope somebody could help me with the creation of a table in sqlite3 from python. I am developing an application that allows a user to import a data file and insert the data into a sqlite3...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.