Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Some methods to run your script

 
Logged in as: Guest
arrSession:exec spGetSession 2,18,62787
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript Tutorial >> Some methods to run your script
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 Some methods to run your script - 7/25/2008 10:15:30 PM   
  TomRiddle


Posts: 165
Score: 4
Joined: 2/7/2008
Status: offline

Anyone can copy and paste some code from the web and run a script, right? You just double click on it right? No wrong, here are a dozen ways to run that little snippet. Some methods described may be done the same by different techniques. Feel free to post more methods tips or corrections, this tutorial is by no means an exhaustive list as I have not mentioned script components, scripts compiled into exe or that you can even run a script from some editors.



1. VBS Launched via wscript engine
Method
: Create a txt file containing the script, rename extension to .VBS, double click on example.vbs

Example Code
:

      

Requirements
: Computer with Windows Scripting host installed, txt editor. IE3+
http://support.microsoft.com/kb/188135

Notes
: Download the latest version of Windows Scripting Host if you are running on an old version of windows



2. VBS Launched via cscript engine
Method
: Create a txt file containing the script, rename extension to .VBS, launch script by typing “cscript example.vbs” from command prompt.
Example Code:

      

Requirements
: Computer with Windows Scripting host installed, txt editor. IE3+
http://support.microsoft.com/kb/188135

Notes
: commonly batch files are used to launch vbs files using the cscript engine, useful in seeing output in console window, output can be piped to a file by adding “>output.txt” at the end of the launch command.



3. VBS Launched via another script
Method
: Create a txt file containing the script below and give it a .vbs extention, Create another vbs file that you wish to run, save in the root of c:\, call it example.vbs and it will be run by the below code.

Example Code for runme.vbs
:

      

Requirements
: Computer with Windows Scripting host installed, txt editor. IE3+
http://support.microsoft.com/kb/188135

Notes
: This script can run any executable. Full syntax is available in the WSH documentation.



4. VBS Launched by Drag and Dropping a file onto it
Method
: Create a txt file with VBS extension and include code that is in the example, Drag and drop a file onto script and file name will be echoed

Example
:

      

Requirements
: Computer with Windows Scripting host installed, txt editor. IE3+
http://support.microsoft.com/kb/188135

Notes
: If you can access the name of the file dropped on your script then you can further manipulate the file via VBScript



5. VBS Launched from Windows Explorer right click file “Send To”
Method
: Create a txt file with VBS extension and include code that is in the example below. Place the VBS file here: C:\Documents and Settings\%UserName%\SendTo

Example
:

      

Requirements
: W2000 or above

Notes
: If this script can echo the name of the file sent to it then you can further manipulate that file via VBScript for example, zip it up and save it in a special folder.



6. VBS Launched from Windows Explorer right click Folder <Your Name>
Method
: Create a txt file with the following name runfolder.vbs and include code that is in the example below.
Place the VBS file here: C:\windows\runfolder.vbs
Create registry key so that computer recognises runfolder.vbs:
HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Folder\shell\<YourName>\Command

Example Code for setting registry key to launch runfolder.vbs
:

      

Example Code for runfolder.vbs
:

      

Requirements
: W2000 or above

Notes
: If this script can echo the name of the folder you clicked on then you can further manipulate that folder via VBScript for example: Scan or copy the folder contents.



7. VBS Launched via Scheduled task
Method
: Create scheduled task to launch your script

Example Code
:

      

Requirements
: Computer with Windows Scripting host installed, txt editor. IE3+
http://support.microsoft.com/kb/188135

Notes
:



8. VBS Launched via WMI remote execute
Method
: Create a simple.vbs script you would like to run on a remote computer, create another script using the below code to copy it to remote machine and then execute it from that machine.

Example Code
:

      

Requirements
: Computer with Windows Scripting host installed, txt editor. IE3+
http://support.microsoft.com/kb/188135

Notes
: There are other utilities that can remote execute scripts but the utility must be installed on the remote machine first.



9. VBS Launched via Windows StartUp Folder
Method
: Create a simple.vbs script you would like to run at windows startup. Copy script to the following folder C:\Documents and Settings\%UserName%\Start Menu\Programs\Startup

Example Code
:

      

Requirements
: Computer with Windows Scripting host installed, txt editor. IE3+
http://support.microsoft.com/kb/188135

Notes
:



10. VBS Launched via registry run key
Method
: Create a simple.vbs script you would like to run on remote computer at windows startup, copy it to the c drive and then reference it from the following registry key [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run] Create new string value pointing to your script.
See other keys in this area for examples

Example Code
:

      

Requirements
: Computer with Windows Scripting host installed, txt editor. IE3+
http://support.microsoft.com/kb/188135

Notes
:



11. HTA
Method
: Create a txt file containing the script, rename extension to .HTA, double click on it.

Example Code
:
http://www.microsoft.com/technet/scriptcenter/topics/htas/tutorial1.mspx

Requirements
: Windows 2000or later and Internet Explorer 5.0 or later.

Notes
: The fist thing you should do is download
Helpomatic which is a HTA itself. This script provides working “copy and paste examples” of most things including a basic HTA which you can build on.
HTA has some VBScript syntax differences to VBS files



12. ASP
Method
: Create a txt file containing the script, rename extension to .ASP place on web server and open via web browser.

Example Code
:

      

Requirements
: Microsoft web server (comes with XP or Windows Server), txt editor

Notes
: ASP has some VBScript syntax differences to VBS and HTA files
Code between these tags <% code %> is executed server side. I.e. if you view the source of the above example from your browser you would only see

      

Notes
: ASP.net and above have higher server requirements but you get the gist. ASP renders HTML so just about any web browser these days will do.
 
 
Post #: 1
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript Tutorial >> Some methods to run your script Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts