|
[VB]Shell - Info, basics, and some examples
|
|||
| Author | Message | ||
|
12-30-2006, 11:57 PM
Post: #1
|
|||
|
|||
|
[VB]Shell - Info, basics, and some examples
Ok, I will be creating this tutorial pretty much all from memory.
First of all the Shell function lets you execute some of the commands you can execute in the Command Prompt (CMD). Shell basically means it'll execute commands in a command prompt shell. Simple yet effective. It's pretty simple, here's a quick example. Code: Private Sub Command1_Click()What that does is it creates another cmd shell. The great thing about the Shell command that you can easily use it to do stuff that would be pretty hard or complex in regular VB code. In VB the code to kill or end a process, is really long, and complex. Ok, so we know some information about the Shell command, and we know that it can make our programming experiance alot easier. But, what are some downfalls? Well, the thing about the Shell command is that it executes a command, and then quickly closes the cmd shell. So how can we fix this? Simple... SendKeys. Code: Private Sub Command1_Click()That will start a cmd shell, and then it'll execcute the ipconfig command which will print information about your connection. Now that code does work, but I don't suggest using it just how it is becuase it's a bit buggy. I know there are times where it'll open alot of cmd shell's and it won't execute the command. If you want to do something like that, you might need to use the API but thats a bit to advanced for this tutorial. Now, we know how the Shell command basically works. But to make sure we understand it, lets make some examples ![]() Code: Private Sub Command1_Click()That will delete the uselessfile.txt file off of the C:\ drive. Code: Private Sub Command1_Click()That will kill Internet Explorer if it's running. Ok, that looks good. How about we start a program? Code: Private Sub Command1_Click()Simple, that code starts up useless.txt in notepad ![]() Now, if you didn't know, you can start alot of programs through the cmd shell by simpley typing it's name like notepad, regedit, and some others. Here are some more examples that some might find usefull. Code: Private Sub Command1_Click()Well that will be all for now. I hope you enjoyed and learned something with this tutorial. And please do rate it
|
|||
|
01-02-2007, 07:17 PM
Post: #2
|
|||
|
|||
|
RE: [VB]Shell - Info, basics, and some examples
Good tutorial, explains well how to co-operate with dos
![]()
|
|||
|
01-03-2007, 08:49 PM
Post: #3
|
|||
|
|||
|
RE: [VB]Shell - Info, basics, and some examples
Thanks for the comment, it's much appreciated.
I needed a good comment to give me a little pick me up ![]() Been sick for about a week now -_- |
|||
|
01-04-2007, 12:01 PM
Post: #4
|
|||
|
|||
RE: [VB]Shell - Info, basics, and some examples
Traxin Wrote:Thanks for the comment, it's much appreciated. Guess what... I got sick yesterday... Been in bed for the whole day now, doing nothing, with a bucket next to it... rofl, but you're welcome
![]()
|
|||
|
04-02-2008, 07:30 PM
(This post was last modified: 04-02-2008 07:32 PM by GearHead.)
Post: #5
|
|||
|
|||
RE: [VB]Shell - Info, basics, and some examples
Traxin Wrote: it should be the following to delete a file Code: Private Sub Command1_Click()
|
|||
|
08-12-2008, 03:51 AM
Post: #6
|
|||
|
|||
|
RE: [VB]Shell - Info, basics, and some examples
He is explaining how to do it with the shell function
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀ - Timothiess : Dreams Create Reality |
|||
|
06-24-2009, 02:29 PM
Post: #7
|
|||
|
|||
|
RE: [VB]Shell - Info, basics, and some examples
for some reason i used the code shell "cmd" but it opened like 6 prompts and i don't know why. is there something i can do to stop this?
|
|||
« Next Oldest | Next Newest »
|













![[Image: Sig.jpg]](http://members.lycos.nl/Omegadesign/Sig.jpg)


View a Printable Version
Send this Thread to a Friend
Subscribe to this thread