Register - Login
Views: 99830195
Main - Memberlist - Active users - Calendar - Wiki - IRC Chat - Online users
Ranks - Rules/FAQ - Stats - Latest Posts - Color Chart - Smilies
05-03-22 09:08:24 PM
Jul - Computers and Technology - [VB08] Sendkeys to open .exe not working? New poll - New thread - New reply
Next newer thread | Next older thread
ShenoxVII

(in all seriousness, you're a prick)
Level: 24


Posts: 54/111
EXP: 76006
For next: 2119

Since: 10-09-10


Since last post: 9.0 years
Last activity: 9.0 years

Posted on 04-24-11 07:55:24 AM Link | Quote
Okay this is my problem. I'm trying to open a program in this case CMD and have the sendkeys directly after program opens to send keys to the program in this case a command.

here is what my code look likes right now (take note i have tried many, many, MANY ways to do this but failed each time)


[Code] 

Dim A, B As String
A = "Ipconfig"
B = "{ENTER}"
Shell("CMD.exe")
SendKeys.Send(A)




Okay so I saw ProcessCmdKey() in suggestions but i couldnt figure out how to use it correctly which i think will solve my problem.

What i need is for it to open Command prompt then do a command. For some reason it will open a bunch of Command prompts non-stop with the enter thing so thats why i dont have it in the code and it doesnt even send the keys. Someone help plz?

____________________
Sukasa

Level: 123


Posts: 3093/4326
EXP: 20936841
For next: 294425

Since: 07-07-07


Since last post: 1.1 years
Last activity: 1.1 years

Posted on 04-24-11 08:20:28 PM (last edited by Sukasa at 04-24-11 05:24 PM) Link | Quote

You'll have more luck by using the Process class. That will let you send strings to the program's stdin, which is a far better alternative.

For example:



        IPConfig= New Process()


IPConfig.StartInfo.UseShellExecute = False
IPConfig.StartInfo.RedirectStandardOutput = True
IPConfig.StartInfo.RedirectStandardInput = True
IPConfig.StartInfo.RedirectStandardError = True
IPConfig.StartInfo.FileName = "ipconfig.exe"
IPConfig.Start()



Then it's just a matter of retreiving the program's output. I do hope, however, that 'ipconfig' is just an example string...

____________________
Witty Text Here
ShenoxVII

(in all seriousness, you're a prick)
Level: 24


Posts: 55/111
EXP: 76006
For next: 2119

Since: 10-09-10


Since last post: 9.0 years
Last activity: 9.0 years

Posted on 04-25-11 08:45:25 PM Link | Quote
Originally posted by Sukasa
You'll have more luck by using the Process class. That will let you send strings to the program's stdin, which is a far better alternative.

For example:



        IPConfig= New Process()


IPConfig.StartInfo.UseShellExecute = False
IPConfig.StartInfo.RedirectStandardOutput = True
IPConfig.StartInfo.RedirectStandardInput = True
IPConfig.StartInfo.RedirectStandardError = True
IPConfig.StartInfo.FileName = "ipconfig.exe"
IPConfig.Start()



Then it's just a matter of retreiving the program's output. I do hope, however, that 'ipconfig' is just an example string...


Thanks! Yes IPconfig was indeed an example of what I was trying to do.

Next newer thread | Next older thread
Jul - Computers and Technology - [VB08] Sendkeys to open .exe not working? New poll - New thread - New reply


Rusted Logic

Acmlmboard - commit 47be4dc [2021-08-23]
©2000-2022 Acmlm, Xkeeper, Kaito Sinclaire, et al.

28 database queries.
Query execution time: 0.081237 seconds
Script execution time: 0.007780 seconds
Total render time: 0.089017 seconds