|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
writing commands to command prompt in VB.NETprompt then write lines to it in VB.NET. Currently I have this code, but it execute's too fast I think because Dim psi As Object = New ProcessStartInfo psi.FileName = "cmd.exe" System.Diagnostics.Process.Start(psi) SendKeys.Send("abcdefg" & "{enter}") SendKeys.Send("12345678" & "{enter}") SendKeys.Send("!@#$%^^&" & "{enter}") The SendKeys.Send()s seem to be executing so fast that the command prompt only catches say efg 78 and & in the commmand prompt. And another thing it seems to do is execute this code twice once for the down mouse click and one for the up maybe? The effect of the program running its code twice varies with how long you hold the button down. I think i need some sort of delays added in but I don't know the function to do that. And I have no clue how to fix the code running twice. Any help reguarding any of these issues is much appreciated! Thank you very much! I figured out how to avoid two coming up by using the Mousedown event
rather than the click event. Although now all of the code is executed before the command prompt is window is created. How do you add delays in VB.NET aside from loops? So what exactly are you trying to accomplish? Maybe there's an easier
way... Thanks, Seth Rowe Shooter4Li***@gmail.com wrote: Show quoteHide quote > I figured out how to avoid two coming up by using the Mousedown event > rather than the click event. Although now all of the code is executed > before the command prompt is window is created. > > How do you add delays in VB.NET aside from loops? Is this what ur looking for?
System.Threading.Thread.Sleep(30000) ' 30 seconds 1000 for every second. u need a pause in between your commands ? Miro <Shooter4Li***@gmail.com> wrote in message Show quoteHide quote news:1159893368.326518.98060@m73g2000cwd.googlegroups.com... >I figured out how to avoid two coming up by using the Mousedown event > rather than the click event. Although now all of the code is executed > before the command prompt is window is created. > > How do you add delays in VB.NET aside from loops? > Shooter4Li***@gmail.com wrote:
> Hi, I am having trouble figureing out the best way to open a command Is abcdefg and 12345678 and the other command batch files that you are> prompt then write lines to it in VB.NET. Currently I have this code, > but it execute's too fast I think because > > Dim psi As Object = New ProcessStartInfo > psi.FileName = "cmd.exe" > System.Diagnostics.Process.Start(psi) > SendKeys.Send("abcdefg" & "{enter}") > > SendKeys.Send("12345678" & "{enter}") > > SendKeys.Send("!@#$%^^&" & "{enter}") > trying to run? If so, look at starting the cmd.exe and passing in the name of the batch file at the argument. Like this: This code will start a batch file and waits for it to exit Private Sub ExecuteBatFile(ByVal batchfilename As String) Using m_Process As New Process() With m_Process.StartInfo .FileName = "cmd.exe" .UseShellExecute = False .CreateNoWindow = True .Arguments = "/C " & batchfilename" End With m_Process.Start() m_Process.WaitForExit(5000) End Using End Sub Hope this helps I was trying to avoid using a batch file just due to some of my feilds
having sensitive information. That isn't the case anymore, but still i'd like to pull this off just using a standard form and pulling up a command prompt and doin what I need to get done. I fixed my problems up there, but have run into a far stranger one. Now im trying to use this statment to copy a couple files from one directory to another through dos with VB.NET. copy \\(server name goes here)\(file name goes here)\ ut* c:\data the ut* is asking for all files with the prefix ut (if you didn't know that) when I send this command to the command prompt using the following statment SendKeys.Send(strPath & "{enter}") where strPath = "copy \\(servername goes here)\(file name goes here)\ut" & ChrW(42) & " c:\data" the only thing that shows up in the command prompt is * c:\data Ive tried it several different ways to varying effect... not sure what is causing the front part to be cut off. Thankyou sooo much for your help :) Shooter4Li***@gmail.com wrote:
> I was trying to avoid using a batch file just due to some of my feilds My example showed how to call a batch file, but if you start cmd.exe as> having sensitive information. That isn't the case anymore, but still > i'd like to pull this off just using a standard form and pulling up a > command prompt and doin what I need to get done. > a process, you can then use the redirected StandardInput to send commands to the command processor: Public Sub ExecuteDOSCommand() Using m_Process As New Process() With m_Process.StartInfo .FileName = "cmd.exe" .UseShellExecute = False .CreateNoWindow = True .RedirectStandardInput = True End With Dim start As DateTime = DateTime.Now m_Process.Start() m_Process.StandardInput.WriteLine("copy /Y \\server\folder\ut* c:\data") m_Process.Close() End Using End Sub > Now im trying to use this statment to copy a couple files from one The copy command would be copy \\servername\ut* c:\data> directory to another through dos with VB.NET. > > copy \\(server name goes here)\(file name goes here)\ ut* c:\data > > the ut* is asking for all files with the prefix ut (if you didn't know > that) You have a space just before the ut*. But why on earth would you want to use the command prompt to copy the files when you can use the classes in the System.IO namespace? Imports System.IO Public Sub CopyFiles() Dim destination As String = "c:\data" Dim filesToCopy() As String = Directory.GetFiles("\\servername\folder", "ut*") For Each filename As String In filesToCopy File.Copy(filename, Path.Combine(destination, Path.GetFileName(filename))) Next End Sub You'll probably want to add some exception handling to handle any errors. > when I send this command to the command prompt using the following I cannot answer this as I do not use SendKeys.> statment > > SendKeys.Send(strPath & "{enter}") > > where strPath = "copy \\(servername goes here)\(file name goes > here)\ut" & ChrW(42) & " c:\data" > the only thing that shows up in the command prompt is * c:\data >
Data Set to Excel ?
vb.net serial IO problem da.update (syntax error in UPDATE statement) VB to C# converter RuntimeHelpers.GetObjectValue Discussion [Newbie] Customize Anchor properties ? Newbie Paint Question SelectedIndexChanged causes selectedindex to reset to -1? Q: Activated Focus problem with the tab control |
|||||||||||||||||||||||