VB icon

all kinds of cool ways of using the shell command

Email
Submitted on: 1/4/2015 9:18:00 AM
By: Half-Dead (from psc cd)  
Level: Beginner
User Rating: By 18 Users
Compatibility: VB 5.0, VB 6.0
Views: 591
 
     These different ways of using the shell command will let you : Launch files without knowing the associated program(doc,bmp,zip,etc), copy files and complete directories, run dos commands, launch a browser, launch an email client with almost all fields prefilled(including body!) and loads of stuff you might think of.
 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
				
'**************************************
' Name: all kinds of cool ways of using the shell command
' Description:These different ways of using the shell command will let you : Launch files without knowing the associated program(doc,bmp,zip,etc), copy files and complete directories, run dos commands, launch a browser, launch an email client with almost all fields prefilled(including body!) and loads of stuff you might think of.
' By: Half-Dead (from psc cd)
'
' Side Effects:You dont get any feedback from VB to check if the operation went well, so use this only for stuff that you are sure about, and dont need error codes returned.
'**************************************

'The vbhide makes sure that ppl dont see that ugly dosbox
Shell ("c:\windows\command\xcopy /e /i /r c:\temp d:\NewTemp"), vbHide
' will create a directory called NewTemp on d: and copy
' all the files and directories recursively from c:\temp
' into it, without showing the dosbox
' you can also run any commands like del, dir, etc
' by running command.com
shell("command.com /c PathandFileToRun Commuters CommandLine"), vbHide
' /c tells command.com to run a command and exit
' you could run somethin like :
Shell ("command.com /c dir /b d:\ > dListing.txt"), vbHide
' and recover all the names of the files in d:
' or run files associated to programs(doc,zip,bmp,etc)
' by using the start command, windows will launch the
' file with the appropriate program
Shell ("start C:\WINDOWS\HELP\WINHLP32.HLP"), vbHide
' if you need even more dos power then you could just as easily run
' some bat files to do bigger operations. I think
' windows scripting host can do some awesome stuff too
' but im not familiar with it at all. All i know is
' that it lets you write javascript and vbscript like
' batch files.
Shell ("start http://www.whatever.com"), vbHide
'Will launch the default webrowser on that page
Shell ("start mailto:me@test.com,next@next.com?cc=whoever@whetever.com&subject=whatever&body=your text"), vbHide
'launch the default email client with most fields prefilled.
'im sure you can attach a file, but i havent found the right
'command yet. also its VERY important the order in which the
'commands are fed. Just separate multiple adresses with a comma
'like above.
'if i find any other cool usages i'll postem up.


Other 4 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Beginner category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments


 There are no comments on this submission.
 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.