wetmatter nonsense

let's get random 
Filed under

vbs

 

vbs: Sub & Function Procedures

First off there are two types of Procedures. Sub Procedures and Function Procedures. One of the main differences is that a Sub Procedure does not return a value whereas a Function Procedure will. I won't bore you to much unnecessary details...

Syntax (Sub Procedure):

Sub ProcedureName(Arg1,Arg2)
     script statements
End Sub

Syntax (Function Procedure):

Function ProcedureName(Arg1,Arg2)
     script statements
End Function

Let's step through a simple process using both types of procedures (no returning values) stating with a Sub.

SubProc

Now let's move on to a Function Procedure.

FuncProc

So far everything is working the same. Now let's try returning a value, shall we? This time we will start with a Function Procedure.

FuncProc_ReturnedVal

Yeah it worked! Now let's try it with a Sub Procedure.

SubProc_Failed

FAIL! Can't do it, won't do it.

SubProc_Error

Filed under  //   function procedure   scripting   sub procedure   vbs   vbscript   vbsedit  
Posted by Samson Loo 

Comments [0]

Simple File Organizer v1.04

This script grabs the date (modified or create date) from the file and
creates a folder based on the date in the following format (MM-DD-YY)
and moves the file into the newly created and designated folder. If
the folder exist then the file is simply moved. NOTE: If the files
have been copied from another pc be sure to uncomment line 53
(tFile.DateLastModified) to use the Modified date instead of the
(tFile.DateCreated), so comment out line 54 before running the script.
Because if the files have a common create date then all files will be
groupped into a single folder.

This script is ideal for unorganized photos still on a media card and
files unorganized in a folder such as downloaded items, but there are
many other uses I suppose.

Example:
Filename1 has a create date of Jan. 13, 2009 then this would be
grouped into a folder called 01-13-09.
Filename2 has a create date of Oct. 17, 2009 then this would be
grouped into a folder called 10-17-09.

VERIFIED ON:
This script has been tested against Windows 2003, XP & Vista.

NOTE: Rename the file from .vbs_ to .vbs and edit line 42 to specify
the target folder before running. This only targets files in the
parent directory, files in sub-directories will not be affected.

See this posted on Microsoft's TechNet Script Center Gallery (http://bit.ly/ePsXU)

     
Click here to download:
Simple_File_Organizer_v1.04.zip (98 KB)

Click here to download:
SimpleFileOrganizer_1.04.vbs_ (2 KB)

Filed under  //   file organizer   vbs   vbscript  
Posted by Samson Loo 

Comments [0]

VBScript References Part 1...

[Display Standard Output]
Wscript.Echo "Hello Samson"

[Display to Message Box]
dim Msg
Msg=MsgBox("Hello Samson!",0,"VBS Example")
0 = (vbOKOnly) Ok button only

dim Msg
Msg=MsgBox("Hello Samson!",2,"VBS Example")
2 = (vbAbortRetryIgnore) Abort, Retry, & Ignore buttons

dim Msg
Msg=MsgBox("Hello Samson!",16,"VBS Example")
16 = (vbCritical) Critical message icon

Set WshShell = Wscript.CreateObject("Wscript.Shell")
WshShell.Popup "Hello Samson!",, "WshShell Popup"

Set WshShell = Wscript.CreateObject("Wscript.Shell")
WshShell.Popup "Hello Samson!",3, "Close in 3 secs",16
3 = Number of seconds to close, 16 = Critical message icon

Filed under  //   vbs  
Posted by Samson Loo 

Comments [0]

WshShell.SendKeys...VBS Script

WshShell.SendKeys...if you think about it there are many things you can do with this. For instance you can turn on or off the CAPS LOCK, NUMLOCK and SCROLL LOCK keys or even write a quick note. I know writing a note is over the top and inefficient but it can be fun to play a trick on your co-workers, friends or family especially if you share a pc! Let's get started...

The first thing you need to do is open up good ol' notepad. Then copy and paste the following script into notepad.

'Start Copy
Set WshShell = WScript.CreateObject("WScript.Shell")
WScript.Sleep 5000
WshShell.Run "notepad"
WScript.Sleep 100 'This gives notepad sometime to open
WshShell.AppActivate "Notepad"
WScript.Sleep 500
x=0
   do while x < 100
      WshShell.SendKeys "I know what you did last summer!"
      WshShell.SendKeys "{ENTER}"
      WScript.Sleep 100
   x=x+1
loop
'End Copy

then close notepad and when prompted save the file with what ever name of your liking, but change the extension from TXT to VBS. Then place it in your friend’s startup. Then the next time they log into their computer they will see notepad open and several lines of "I know what you did last summer!" will begin to write automagically! This is great for Halloween pranks!

Visit Winstructor to brush up on addtional functions...Website

Filed under  //   sendkeys   vbs   wshShell  
Posted by Samson Loo 

Comments [0]