create and execute bat file in vb.net

E

Eric Wood

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?
 
Joined
Jun 26, 2007
Messages
1
Reaction score
0
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.
 
Joined
Jul 10, 2007
Messages
2
Reaction score
0
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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,222
Members
46,809
Latest member
moe77

Latest Threads

Top