473,396 Members | 2,087 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,396 software developers and data experts.

process.start(filename), shell(filename) weird behavior

Hi group,

I've got a program that creates a bat and a sql file and then executes the
bat file

the bat file is called temp.bat
and looks like this:

osql -U"user" -P"password" -S"pcname\instance" -i temp.sql -o temp.txt

the temp.sql file that's called as input in the bat file looks like this:
use pfd
drop table ea005temp
select * into ea005temp from ea005
delete from ea005temp

now the problem is when I call the bat file from my program with
shell(filename) or process.start(filename) or process.start("osql",
"-U"user" -P"password" -S"pcname\instance" -i temp.sql -o temp.txt") I see
the dos window open but the bat file doesn't get executed, but when I double
click the bat file it runs just fine.
Anyone knows what could be the problem?

Greetz Peter

Nov 21 '05 #1
6 3208
Hi group I've found the answer myself, when I call the shell it starts the
cmd at c:\ and there it doesn't find the files temp.sql and temp.txt because
they're created in the application.startuppath just like the bat file and
that's why it didn't work but it did when I double clicked the bat because
then it starts the cmd at the correct path

greetz Peter

"Peter Proost" <pp*****@nospam.hotmail.com> wrote in message
news:uH**************@TK2MSFTNGP09.phx.gbl...
Hi group,

I've got a program that creates a bat and a sql file and then executes the
bat file

the bat file is called temp.bat
and looks like this:

osql -U"user" -P"password" -S"pcname\instance" -i temp.sql -o temp.txt

the temp.sql file that's called as input in the bat file looks like this:
use pfd
drop table ea005temp
select * into ea005temp from ea005
delete from ea005temp

now the problem is when I call the bat file from my program with
shell(filename) or process.start(filename) or process.start("osql",
"-U"user" -P"password" -S"pcname\instance" -i temp.sql -o temp.txt") I see
the dos window open but the bat file doesn't get executed, but when I double click the bat file it runs just fine.
Anyone knows what could be the problem?

Greetz Peter


Nov 21 '05 #2
Peter,

I had no answer however a nice method to install msde

I assumed that you did look already if ProcessStartInfo could help you?

:-)

Cor
Nov 21 '05 #3
"Peter Proost" <pp*****@nospam.hotmail.com> schrieb:
now the problem is when I call the bat file from my program with
shell(filename) or process.start(filename) or process.start("osql",
"-U"user" -P"password" -S"pcname\instance" -i temp.sql -o temp.txt") I see
the dos window open but the bat file doesn't get executed, but when I
double
click the bat file it runs just fine.
Anyone knows what could be the problem?


Try to set the working directory:

\\\
Imports System.Diagnostics
..
..
..
Dim psi As New ProcessStartInfo()
With psi
.FileName = "osql"
.Arguments = ...
.WorkingDirectory = "C:\MySQLScripts"
End With
Process.Start(psi)
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #4
Thnx, for your answer Herfried, I had already found out myself that that was
the problem (see my previous post) But thnx again

greetz Peter

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:uk**************@TK2MSFTNGP10.phx.gbl...
"Peter Proost" <pp*****@nospam.hotmail.com> schrieb:
now the problem is when I call the bat file from my program with
shell(filename) or process.start(filename) or process.start("osql",
"-U"user" -P"password" -S"pcname\instance" -i temp.sql -o temp.txt") I see the dos window open but the bat file doesn't get executed, but when I
double
click the bat file it runs just fine.
Anyone knows what could be the problem?


Try to set the working directory:

\\\
Imports System.Diagnostics
.
.
.
Dim psi As New ProcessStartInfo()
With psi
.FileName = "osql"
.Arguments = ...
.WorkingDirectory = "C:\MySQLScripts"
End With
Process.Start(psi)
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #5
Cor,

I don't actualy use it to install msde, but I've written a sort of msde
manager, because my program will be installed with our company distributors
in Belgium/France and the Netherlands and to make my colleague, who has to
go and install the program and perfrom database updates, his work easier
I've written a .net program to view/export/import and update the tables and
backup and restore the msde database. So if you or anyone else ever needs
anything like this.

Greetz Peter

"Cor Ligthert" <no************@planet.nl> wrote in message
news:Os**************@TK2MSFTNGP15.phx.gbl...
Peter,

I had no answer however a nice method to install msde

I assumed that you did look already if ProcessStartInfo could help you?

:-)

Cor

Nov 21 '05 #6
Peter, would be interested in seeing how you worked with the MSDE database. I have another project that I will be working on (
once I get thru the mess I'm working on now) that will probably involve MSDE.
If you are willing to share the code that would be nice.
james

email: jjames700 AT earthlink DOT net
(maybe that will slow up the spammers! )
"Peter Proost" <pp*****@nospam.hotmail.com> wrote in message news:%2****************@TK2MSFTNGP09.phx.gbl...
Cor,

I don't actualy use it to install msde, but I've written a sort of msde
manager, because my program will be installed with our company distributors
in Belgium/France and the Netherlands and to make my colleague, who has to
go and install the program and perfrom database updates, his work easier
I've written a .net program to view/export/import and update the tables and
backup and restore the msde database. So if you or anyone else ever needs
anything like this.

Greetz Peter

"Cor Ligthert" <no************@planet.nl> wrote in message
news:Os**************@TK2MSFTNGP15.phx.gbl...
Peter,

I had no answer however a nice method to install msde

I assumed that you did look already if ProcessStartInfo could help you?

:-)

Cor


Nov 21 '05 #7

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

Similar topics

0
by: Lin JinCong | last post by:
Dim p As Process = System.Diagnostics.Process.Start(filename) p.WaitForExit() Open a file use above method, and use WaitForExit method to wait, when file is MS Word file, p equal to nothing....
6
by: Cosmin Spirescu | last post by:
Hi, It should be something very simple, but I do not know what I do wrong. I display some PDF filenames form a folder into a gridview and when the user clicks on the name, it execute this...
4
by: Zorpiedoman | last post by:
dim FileName as string = "Test.doc" dim P as Process = Process.Start(FileName) '--P is NOTHING even though document opens!!! dim Q as new process Q.StartInfo.FileName = FileName P = Q.start...
7
by: =?Utf-8?B?ams=?= | last post by:
I am using System.Diagnostics.Process class to open a word document by call ing Process.Start("test.doc"). I am using C# as programming language. On some of the computers on running this code i get...
2
by: Matt F | last post by:
I have a relatively long command that I'm attempting to get process.start to execute. When executing the command, I get a "The system cannot find the file specified" error. I've gone to the...
3
by: samdotnetprogrammer | last post by:
Hi, I am developing a small application using VB.NET. I have a datagrid which has a hyperlink column. The hyperlink column will contain path to a filename. eg. c:\vbdotnet.doc When I run my...
7
by: geoffbache | last post by:
Am currently being very confused over the following code on Windows import subprocess, os file = open("filename", "w") try: proc = subprocess.Popen("nosuchprogram", stdout=file) except...
0
by: Michael Leithold, WWK | last post by:
Hello, If I loop through all the processes on my machine, for some processes I get "Access Denied" when trying to read the file name associated with the process. Also some other properties are...
5
by: sjoshi23 | last post by:
Hello I'm trying to start a remote desktop session using Process.Start but it keeps saying "File not found". The same cmd thru DOS window works fine. I used: C:\\WINDOWS\\system32\\mstsc.exe...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.