Hello,
I have a simple batch file that I'm trying to call from a VB.NET
application:
@ECHO OFF
IF (%1)==() GOTO END
DIR %1 > MYDIR.TXT
:END
@ECHO ON
In VB.NET I can call the batch file without the sMYDir parameter:
System.Diagnost ics.Process.Sta rt(AppDomain.Cu rrentDomain.Bas eDirectory
& "saveMylist .bat ")
But when I add my parameter:
System.Diagnost ics.Process.Sta rt(AppDomain.Cu rrentDomain.Bas eDirectory
& "saveMylist .bat " & sMYDir)
I get:
"The system cannot find the file specified"
Does anyone have an idea how to work around this? I don't want to hard
code the path in my batch file.
AppDomain.Curre ntDomain.BaseDi rectory is:
"C:\Documen ts and Settings\MyUser \My Documents\Visua l Studio
2005\Projects\M yProj\bin\Debug \"
I had problems with spaces i the patch when I tried running the command
from a command prompt, so I tried changing the commandline to:
System.Diagnost ics.Process.Sta rt(ControlChars .Quote &
AppDomain.Curre ntDomain.BaseDi rectory & "saveMylist.bat " " &
ControlChars.Qu ote & " " & sMYDir)
and get the same error.
I CAN run the complete concatenated string returned by
(ControlChars.Q uote & AppDomain.Curre ntDomain.BaseDi rectory &
"saveMylist.bat " " & ControlChars.Qu ote & " " & sMYDir) from the
command prompt with no errors, but it doesn't work when I call it from
System.Diagnost ics.Process.Sta rt.
Thanks,
Eric 6 20412
eric.gofo...@gm ail.com wrote: I had problems with spaces i the patch when I tried running the command from a command prompt, so I tried changing the commandline to:
System.Diagnost ics.Process.Sta rt(ControlChars .Quote & AppDomain.Curre ntDomain.BaseDi rectory & "saveMylist.bat " " & ControlChars.Qu ote & " " & sMYDir)
I had an extra quote in there, it should be:
System.Diagnost ics.Process.Sta rt(ControlChars .Quote &
AppDomain.Curre ntDomain.BaseDi rectory & "saveMylist.bat " &
ControlChars.Qu ote & " " & sMYDir)
Eric,
I am not sure if I understand your question but have a look at this. http://msdn2.microsoft.com/en-us/lib...olderpath.aspx
if you are using version 2005 you can as well look to this. http://msdn2.microsoft.com/en-us/lib...f7(vs.80).aspx
I hope this helps,
Cor
<er**********@g mail.com> schreef in bericht
news:11******** **************@ p79g2000cwp.goo glegroups.com.. . Hello,
I have a simple batch file that I'm trying to call from a VB.NET application:
@ECHO OFF IF (%1)==() GOTO END DIR %1 > MYDIR.TXT :END @ECHO ON
In VB.NET I can call the batch file without the sMYDir parameter:
System.Diagnost ics.Process.Sta rt(AppDomain.Cu rrentDomain.Bas eDirectory & "saveMylist .bat ")
But when I add my parameter:
System.Diagnost ics.Process.Sta rt(AppDomain.Cu rrentDomain.Bas eDirectory & "saveMylist .bat " & sMYDir)
I get:
"The system cannot find the file specified"
Does anyone have an idea how to work around this? I don't want to hard code the path in my batch file.
AppDomain.Curre ntDomain.BaseDi rectory is:
"C:\Documen ts and Settings\MyUser \My Documents\Visua l Studio 2005\Projects\M yProj\bin\Debug \"
I had problems with spaces i the patch when I tried running the command from a command prompt, so I tried changing the commandline to:
System.Diagnost ics.Process.Sta rt(ControlChars .Quote & AppDomain.Curre ntDomain.BaseDi rectory & "saveMylist.bat " " & ControlChars.Qu ote & " " & sMYDir)
and get the same error.
I CAN run the complete concatenated string returned by (ControlChars.Q uote & AppDomain.Curre ntDomain.BaseDi rectory & "saveMylist.bat " " & ControlChars.Qu ote & " " & sMYDir) from the command prompt with no errors, but it doesn't work when I call it from System.Diagnost ics.Process.Sta rt.
Thanks, Eric
Try this:
Dim process As New System.Diagnost ics.Process
Dim startInfo As New ProcessStartInf o( _
ControlChars.Qu ote & AppDomain.Curre ntDomain.BaseDi rectory &
"saveMylist.bat ", sMYDir)
process.StartIn fo = startInfo
process.Start()
--
Carsten Thomsen
Communities - http://community.integratedsolutions.dk
---------
Voodoo Programming: Things programmers do that they know shouldn't work but
they try anyway, and which sometimes actually work, such as recompiling
everything. (Karl Lehenbauer)
---------
<er**********@g mail.com> wrote in message
news:11******** **************@ g10g2000cwb.goo glegroups.com.. . eric.gofo...@gm ail.com wrote:
I had problems with spaces i the patch when I tried running the command from a command prompt, so I tried changing the commandline to:
System.Diagnost ics.Process.Sta rt(ControlChars .Quote & AppDomain.Curre ntDomain.BaseDi rectory & "saveMylist.bat " " & ControlChars.Qu ote & " " & sMYDir)
I had an extra quote in there, it should be:
System.Diagnost ics.Process.Sta rt(ControlChars .Quote & AppDomain.Curre ntDomain.BaseDi rectory & "saveMylist.bat " & ControlChars.Qu ote & " " & sMYDir)
CT wrote: Try this:
Dim process As New System.Diagnost ics.Process Dim startInfo As New ProcessStartInf o( _ ControlChars.Qu ote & AppDomain.Curre ntDomain.BaseDi rectory & "saveMylist.bat ", sMYDir) process.StartIn fo = startInfo
process.Start()
Thanks, that fixed it.
-Eric
"CT" <ca******@spamm ersgoawayintegr asol.dk> schrieb: Dim process As New System.Diagnost ics.Process Dim startInfo As New ProcessStartInf o( _ ControlChars.Qu ote & AppDomain.Curre ntDomain.BaseDi rectory & "saveMylist.bat ", sMYDir) process.StartIn fo = startInfo
process.Start()
.... or 'Process.Start( <batch file>, <arguments>)' .
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/> er**********@gm ail.com wrote: I have a simple batch file that I'm trying to call from a VB.NET application:
@ECHO OFF IF (%1)==() GOTO END DIR %1 > MYDIR.TXT :END @ECHO ON
I presume that your batch file performs other processes as well but you
can duplicate this functionality using the classes in the System.IO
namespace. What is done with the output file, mydir.txt, after you have
created it? This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Vinod |
last post by:
Hi,
I have a problem, i am calling an exe from asp program. Its not working
fine.
When i execute the exe through the dos program directly i get the desired
result.
My exe will convert files in the folder to encrypted files.
But when i call it thru asp program its not working fine. I have tried the
following method.
|
by: Steve Jorgensen |
last post by:
I remember that I used to set up utility batch files, and create Windows
shortcuts to them that would ask the user for parameters to supply to the
batch files. From what I can tell, this functionality simply doesn't exist
anymore in Windows 2000 or above. I did find a work-around to this that I
thought y'all might want to know about.
There are a number of new fetures in batch files available on Windows 2000
including an extended syntax...
|
by: w.monthard |
last post by:
Hi,
here is my trouble:
I need to call 2 différents processes in a same dos window,
the first one is needed for the 2nd, and I have to pass several different
arguments to the 2nd.
My problem is that there are as many dos windows as calls to
"myProcess.start()", and I don't know how to do ...
Anybody has an idea ?
|
by: Bucky Pollard |
last post by:
I have a web service that needs to create a batch file and call it (since
there are no APIs for the functionality I am looking for). I am using the
Process and ProcessStartInfo objects. When I try to call the batch file, it
just returns with a return code of 1. When I call cmd.exe, and pass the
batch file as a parameter it hangs. After much frustration and aggrevation,
I found that CMD IS in fact running, but it is running under the context...
|
by: Uday |
last post by:
hi everyone,
I searched in faq's but couldn't find and solution...
so here I post the popular question..
Env: Win2003 server / IIS6.0
Simple ASP page that runs a batch file.
When I run the asp page, I see some command line window pop-up on my screen
for a second . But the
batch file is not executed. I gave 'IUSR_*' account 'full control'.
| |
by: steve |
last post by:
Hi all,
Here's some work in progress that should allow you to run a batch file as a
custom action in a VS deployment project. Yup I know you can use js or wsh,
but the target may not have either.. Essentially it's just a wrapper for the
Process class and a command interpreter.
Warning, it only partly works. I had wanted to pass in
(a) The name of the batch file (through "BatchFileName"), and
|
by: ed |
last post by:
Hi all,
I'm very new to vb (2nd day) and I need to create a small app that will
replace my old batch file with a flashy gui. I had some experience
with access 2.0 which helps ;)
What I would like is to get the output of the batch file to display on
the gui as the batch file is running.
if some of you understand unix... I want this: tail -f
/var/log/messages
|
by: ck9663 |
last post by:
hi guys this is a little challenging, at least for me...here goes...
i have to run a DOS batch file from a server. with some parameters that i need to pass. these parameters can be found on a sql-server table. which means i need to build the string that will be used to call the batch file (set @var = 'callbatch.bat ' + @var1 + ' ' + @var2). then call the batch file using the xp_cmdshell command. each batch file runs about 4-5 hours. i don't...
|
by: =?Utf-8?B?VkIgSm9ubmll?= |
last post by:
ASP.NET 2.0 / Visual Studio 2005 / VB.Net 2.0
I have a web interface that needs to launch a java application.
What a long strange trip it has been...
I am using Process.Start process start info parameters, first to launch the
java app by itself with the call:
"C:\Program Files\Java\jdk1.5.0_12\bin\java.exe" javaAppName Arg1 Arg2
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |