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

exteral program control

hi, would it be possible for my program to open another program, disk defrag
for example, push the "defrag" button, then wait for it to be done, then
close it? thanks
Nov 21 '05 #1
4 991
iwdu15 wrote:
hi, would it be possible for my program to open another program, disk defrag
for example, push the "defrag" button, then wait for it to be done, then
close it? thanks


I know you can do that but you have to find the windows handle to the
defrag window and then figure out the coords to the button. It would
seem a lot easier to use the command-line utility in defag to do it.
Look in the defrag help file it talks about it in there. As to
launching the process from VB. Look at the Process class and the
Process.Start method. Also have a look at the ProcessInfo class.

Good luck
Chris
Nov 21 '05 #2
i tried that and all i got was a mess....heres my code:
Dim defrag As New Process
Dim defragSI As New ProcessStartInfo("C:\windows\system32\cmd.exe")

Private Sub Form1_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.Load

defrag.StartInfo = defragSI
defrag.StartInfo.UseShellExecute = False
defrag.StartInfo.RedirectStandardInput = True
defrag.Start()

Try
defrag.StandardInput.WriteLine("defrag c: /f")
defrag.WaitForExit()
Catch ex As Exception

End Try

End Sub

and all that happens is my form and the command prompt, for some reason,
loop and make a new prompt and form over and over. what am i doin wrong?
Nov 21 '05 #3
iwdu15 wrote:
i tried that and all i got was a mess....heres my code:
Dim defrag As New Process
Dim defragSI As New ProcessStartInfo("C:\windows\system32\cmd.exe")

Private Sub Form1_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.Load

defrag.StartInfo = defragSI
defrag.StartInfo.UseShellExecute = False
defrag.StartInfo.RedirectStandardInput = True
defrag.Start()

Try
defrag.StandardInput.WriteLine("defrag c: /f")
defrag.WaitForExit()
Catch ex As Exception

End Try

End Sub

and all that happens is my form and the command prompt, for some reason,
loop and make a new prompt and form over and over. what am i doin wrong?


You don't want to start a cmd.exe process, you want to start a dfag.msc
(think that's right, but look at the shortcut you use to launch defrag
from windows) process with some command line option that are in the help
file. You don't need to send anything to standardinput, you are
starting the defrag program directly.

Chris
Nov 21 '05 #4
i cant find the commands in the help file, the only thing i can find is it
using the command prompt...and after i get the commands, how would i tell
Disk Defrag to do that?

Nov 21 '05 #5

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

Similar topics

1
by: Alexander Stante | last post by:
Hi, I know Python since about 3 days or so and I like it very much :-) I am currently tying to control an external console driven program but I have encountered some problems while trying to do...
3
by: Robert | last post by:
Hi all, I am writing programs of algorithms using C++ and C. When I run the programs, I found the programs take 100 percent of the CPU usage and I cannot run any other program. How to control...
8
by: Quentin Huo | last post by:
Hi: I want to run cacls.exe to check the user right from an ASPX page. In ASP, I can do: Set wshobj=Server.CreateObject("WScript.Shell") resobj=wshobj.Run("cmd /c echo Y| cacls c:", 0, True)...
4
by: fripper | last post by:
I have replaced an older machine with a new one and have moved a VB .Net program that I worte on the old machine to the new one. The program uses a FlexGrid control for displaying some stuff in a...
7
by: Buck Rogers | last post by:
Hi all! Newbie here. Below is an example from Teach Yourself C in 21 Days. My apologies if it is a bit long. What I don't understand is how the "get_data" function can call the...
2
by: Michael D. Reed | last post by:
I am using ClickOnce to distribute a program. It works well except for one detail. When a new version is installed, the program does not initialize properly immediately after the update. The...
0
by: vve | last post by:
I'm discovering a strange behaviour in an C# project using ZedGraph (https://sourceforge.net/projects/zedgraph/). After adding a signal to it, it seems that the clr goes mad for some reason. I...
11
by: socialanxiety | last post by:
i hope someone here can help me. basically, me and my friend have a summer project. in this project, we need something that would basically function as a blender. we know we'll need to buy a...
3
by: 100grand | last post by:
Modify the Inventory Program to use a GUI. The GUI should display the information one product at a time, including the item number, the name of the product, the number of units in stock, the price...
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...
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...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
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)...
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.