473,785 Members | 2,830 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Trouble with "Process's" please help!

Ok so I'm trying to run a simple dos command shell through a VB.NET
2005 program. The oddest thing is happening given the following piece
of code:
'============== =============== =============== =============== =
'=== VARIABLE DECLARATION AND INITIALIZATION =============== =
'============== =============== =============== =============== =
'---General Variables------------------------------------
Dim CMDProcess As Process = New Process
'---End General Variables--------------------------------
'---XLNT Shell Variables---------------------------------
CMDProcess.Star tInfo.FileName = "cmd.exe"
CMDProcess.Star tInfo.Arguments = "\c md C:\temp\temp"
'---End XLNT Shell Variables-----------------------------
'============== =============== =============== =============== =
'=== END VARIABLE DECLARATION AND INITIALIZATION ============
'============== =============== =============== =============== =

'============== =============== =============== =============== =
'=== EXECUTE JOB AND KEEP TRACK OF TIME =============== ======
'============== =============== =============== =============== =
CMDProcess.Star t() <--- Does not work
Process.Start(" cmd.exe", "/c md C:\temp\temp") <---- Works
If I create a new instance of the "Process" object and then try to
start it, the command will not work. But if I just simply call
Process.start the command works!

I need to be able to use the created object to do this job. If anyone
could offer any thoughts I would be very appreciative.

Thanks
Matt

Aug 22 '06 #1
5 1610
When you say the command doesn't work...what is the behavior? Do you get any
errors, is there a message box, does an exception get thrown? And if
so...what is the message?

I’m wondering if the CMDProcess object is able to actually find cmd.exe.

Kim Greenlee

--
digipede - Many legs make light work.
Grid computing for the real world.
http://www.digipede.net
http://krgreenlee.blogspot.net

Aug 22 '06 #2
I checked my process start program and the only difference I an see that I
have and you have is the
Dim of the Processes in the begining. This works for me... dont know if you
want to see if it works for u.

my code is as follows:
Dim StartInfo As New ProcessStartInf o()
Dim myNewApp As New Process()

myNewApp.StartI nfo.FileName = "C:\FILENAME.EX E"
myNewApp.StartI nfo.Arguments = "/Q"
myNewApp.StartI nfo.WorkingDire ctory = "C:\Temp"
myNewApp.StartI nfo.WindowStyle = ProcessWindowSt yle.Normal

myNewApp.Start( )
Miro
"Matt" <Kr****@gmail.c omwrote in message
news:11******** *************@b 28g2000cwb.goog legroups.com...
Ok so I'm trying to run a simple dos command shell through a VB.NET
2005 program. The oddest thing is happening given the following piece
of code:
'============== =============== =============== =============== =
'=== VARIABLE DECLARATION AND INITIALIZATION =============== =
'============== =============== =============== =============== =
'---General Variables------------------------------------
Dim CMDProcess As Process = New Process
'---End General Variables--------------------------------
'---XLNT Shell Variables---------------------------------
CMDProcess.Star tInfo.FileName = "cmd.exe"
CMDProcess.Star tInfo.Arguments = "\c md C:\temp\temp"
'---End XLNT Shell Variables-----------------------------
'============== =============== =============== =============== =
'=== END VARIABLE DECLARATION AND INITIALIZATION ============
'============== =============== =============== =============== =

'============== =============== =============== =============== =
'=== EXECUTE JOB AND KEEP TRACK OF TIME =============== ======
'============== =============== =============== =============== =
CMDProcess.Star t() <--- Does not work
Process.Start(" cmd.exe", "/c md C:\temp\temp") <---- Works
If I create a new instance of the "Process" object and then try to
start it, the command will not work. But if I just simply call
Process.start the command works!

I need to be able to use the created object to do this job. If anyone
could offer any thoughts I would be very appreciative.

Thanks
Matt

Aug 22 '06 #3
Matt wrote:
Dim CMDProcess As Process = New Process
CMDProcess.Star tInfo.FileName = "cmd.exe"
CMDProcess.Star tInfo.Arguments = "\c md C:\temp\temp"
CMDProcess.Star t() <--- Does not work
Process.Start(" cmd.exe", "/c md C:\temp\temp") <---- Works
Have a play with the StartInfo UseShellExecute property.
IIRC, that has some bearing on how things work.

Failing that, try "%COMSPEC%" instead of "cmd.exe"

Or, better still, looking at what you're actually doing:

System.IO.Direc tory.CreateDire ctory( "C:\temp\te mp" )

HTH,
Phill W.
Aug 23 '06 #4
I'm not trying to create a directory, that was just something I tossed
in there to see if it would work. What I'm ultimately trying to do is
to run dos commands from a VB.NET app.

I was under the impression given the following code.

Dim StartInfo As New ProcessStartInf o()
Dim myNewApp As New Process()
myNewApp.StartI nfo.FileName = "cmd.exe"
myNewApp.StartI nfo.Arguments = "\c md C:\temp\temp"
myNewApp.StartI nfo.WorkingDire ctory = "C:\Temp"
myNewApp.StartI nfo.WindowStyle = ProcessWindowSt yle.Normal
myNewApp.Start( )

That the "Arguments" part of it would indicate what dos command I
wanted to execute. When I run the following code I get a dos window
showing up but it doesn't make a directory. How do I get it to execute
it?

The reason I want to do things this way is so that I can measure when
the process ends, whereas if I just did it like this...

Process.Start(" cmd.exe", "/c " & Command)

I can't tell.

Aug 23 '06 #5
Matt wrote:
I'm not trying to create a directory, that was just something I tossed
in there to see if it would work.
Fair enough.
myNewApp.StartI nfo.FileName = "cmd.exe"
myNewApp.StartI nfo.Arguments = "\c md C:\temp\temp"
Shouldn't that be "/c md C:\temp\temp" ?
The reason I want to do things this way is so that I can measure when
the process ends, whereas if I just did it like this...

Process.Start(" cmd.exe", "/c " & Command)

I can't tell.
That's because when you kick off a /Windows/ process from /DOS/, DOS
doesn't wait for it to finish /unless/ you use the START command with
the "/WAIT" flag, effectively

START /WAIT winprog1.exe a b c d
IF ERRORLEVEL 1 GOTO Boom

The VB.Net way to start and wait for a Process would be more like this:

With myNewApp.StartI nfo
.FileName = "program1.e xe"
.Arguments = "a b c"
.Start()
.WaitForExit( ... ' can't remember the arguments; sorry
End With

HTH,
Phill W.
Aug 24 '06 #6

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

Similar topics

9
715
by: Paul | last post by:
Hi, VB.NET is saying the file I am creating is in use by another process and won't complete its task of moving the file to the specified destination folder. Here is my code (the main bit anyway).... Private Sub LogChange(ByVal source As Object, ByVal e As System.IO.FileSystemEventArgs) If e.ChangeType = WatcherChangeTypes.Created Then
3
3691
by: Loane Sharp | last post by:
Hi there I use the FileStream object to download a zip file over the internet to my local disk. The file downloads successfully, but when I attempt to unzip it, I'm told that the file is in use by another process. This occurs even if I release the object using fs.Close() and fs = Nothing. Please help (my code is given below) Best regards
8
3228
by: Henrik | last post by:
Hi Is there any way to see what the System process is doing? We have developed an application running at a production site to measure and optimize the production. The application needs to be responsive at all times during production. I'm experiencing some problems with my application not responding or responding slow. I suspeced the problem had to do with high CPU utilization
4
2727
by: hagaihe | last post by:
Hello, I've written a Windows service and i need help to implement the meaning of the sentence which is generated automatically by the IDE // More than one user Service may run within the same process. To add // another service to this process, change the following line to // create a second service object. For example, // // ServicesToRun = new System.ServiceProcess.ServiceBase {new Service1(), new MySecondUserService()};
0
9645
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, 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...
1
10093
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9952
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8976
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, 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...
1
7500
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6740
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();...
1
4053
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
2
3654
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2880
bsmnconsultancy
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...

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.