I have been trying to use the Shell method, but I can't seem to make the
command window activate the way you can with calc or word or notepad... It
is making it impossible to use the SendKeys function, which would be
ideal... I will take a look at the suggestion you gave me, but the Shell
looks like it would be the way to go, if I could just get the focus to the
window without errors.
The code is simple and works for everything except a DOS command window.
Dim myLng As Integer = Shell("NET SHARE tshare /DELETE",
AppWinStyle.NormalFocus)
AppActivate(myLng)
SendKeys.SendWait("y")
SendKeys.SendWait("{Enter}")
That should work and does if you substitute notepad, word, etc instead of
any DOS command, for some reason Windows cannot find the Command Window to
set focus.
I am using NET SHARE to unshare a directory on a server so that some file
maintence can be done at night, even though some users still leave their
computers attached to the share. I cannot find a /y to answer affermative
and ECHO y| doesn't work for it either, or I would be using a simple batch
file to do this.
"Chris Dunaway" <dunawayc@_lunchmeat_sbcglobal.net> wrote in message
news:1k*****************************@40tude.net...
On Mon, 9 Feb 2004 14:51:07 -0500, Atley wrote:
I don't see how that allows me to execute a DOS command, I tried a
simple one like 'dir c:\windows'
and it put it in the console window, but I did not see it execute.
What am I doing wrong?
"Ken Tucker [MVP]" <vb***@bellsouth.net> wrote in message
news:up**************@tk2msftngp13.phx.gbl... Hi,
Dim arArgs() As String = Environment.GetCommandLineArgs
http://msdn.microsoft.com/library/de...eargstopic.asp
Ken
--------------------
Look at the System.diagnostics.Process class. You can call the
Process.Start method to start a DOS command. You can optionally, redirect
the output of the DOS command. When you receive a certain output such as
"Are You Sure?" You can send the appropriate response. Search Google for
examples on redirecting input and you should find a link with an example.
Just FYI (and I'm sure you already know this) most DOS commands that ask
"Are You Sure?" also provide a switch /y for answering yes.
Regards,
--
Chris
To send me an E-mail, remove the underscores and lunchmeat from my E-Mail
address.