Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Frequently Asked Stuff

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

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Frequently Asked Stuff
  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 >>
 Frequently Asked Stuff - 5/15/2007 10:36:26 AM  1 votes
  dm_4ever


Posts: 1941
Score: 30
Joined: 6/29/2006
From: Orange County, California
Status: offline
Frequently Asked Stuff - Updated 04/24/2008

Just posting links or code to various questions I have seen members ask...will try to update often. 

Why bother with this when people can Search like we often recommend members to do? Well, because if you're new you probably don't know the keywords to search for and if you do...you may not find it even though you remember seeing it.

If you are new here, Welcome, and make sure to read this post since it has a lot of useful information: http://www.visualbasicscript.com/m_24727/tm.htm

TIP: Running your script using cscript.exe in conjunction with WScript.Echo is a great way to debug you code and ensure you are getting/setting the values you want.





Informative/Tutorial Links
1.  HTML (good practice by TNO):  http://www.visualbasicscript.com/m_58515/tm.htm
2.  HTML DOM:  http://www.w3schools.com/htmldom/default.asp




Active Directory Browsing
1.
  Active Directory Explorer is similar to ADSI; you can see the objects properties by simply selecting it; date/time values are converted for easy reading as well.
http://technet.microsoft.com/en-us/sysinternals/bb963907.aspx

Add current date to file name; How do I format the current date to include it in the file name? 
1.  This could be one way to achieve this...

      
2.  Another format date function

      
3. ...and another example

      

Add or include external vbs files in a script
You can use ExecuteGlobal to accomplish this
1.  http://www.visualbasicscript.com/m_29285/tm.htm
2.  http://www.visualbasicscript.com/m_47332/tm.htm

AD (Active Directory) Queries
1.  http://www.visualbasicscript.com/m_40609/tm.htm

Compare 2 text files; How can I compare the content of two text files?
1.  http://www.microsoft.com/technet/scriptcenter/resources/qanda/may07/hey0524.mspx

CSV Parsing
1.  http://www.visualbasicscript.com/m_42611/tm.htm

CSV To XLS
1.  You can open it as a .CSV with Excel and save it as a .XLS

      

CSV/Tab Seperated text file parsing using ADO
1.  http://msdn2.microsoft.com/en-us/library/ms974559.aspx
2.  http://www.microsoft.com/technet/scriptcenter/resources/qanda/may05/hey0524.mspx

DSOFile.dll; read & write file properties such as author, title, comments, keywords, etc.
1.  http://www.microsoft.com/downloads/details.aspx?FamilyID=9ba6fac6-520b-4a0a-878a-53ec8300c4c2&DisplayLang=en (download DLL)
2.  http://www.microsoft.com/technet/scriptcenter/resources/qanda/oct04/hey1001.mspx
3.  http://www.microsoft.com/technet/scriptcenter/resources/tales/sg0305.mspx

Directory; get subdirectories using WMI where folders contain characters such as { } '
1.  To get around this you need to use a pair of double quotes instead of single when specifying the directory name and use two \\ instead of one. See the example below.

      

Dynamic Constant; set a constant at time of execution
I know this is a contradiction...but DiGiTAL.SkReAM shows a way of accomplishing this using ExecuteGlobal ...especially since he knows how ebgreen feels about this "hack"
1.  http://www.visualbasicscript.com/m_46780/tm.htm

E-Mail
1.  One way

      

Encryption
1.  http://www.4guysfromrolla.com/webtech/010100-1.shtml
2.  http://www.visualbasicscript.com/m_48428/tm.htm

Excel - Save/Convert to CSV
1.  http://www.visualbasicscript.com/m_46004/tm.htm

Free COM Objects:
1.  http://www.visualbasicscript.com/m_54830/tm.htm
2.  http://www.xstandard.com/en/downloads/

FTP
1.  http://www.chilkatsoft.com/ChilkatFtp.asp
2.  http://www.visualbasicscript.com/m_44703/tm.htm
3.  FTP Search
4.  Free FTP DLL http://www.primalscript.com/Free_Tools/index.asp

Function/Sub - Global & Local variables
1. 
http://www.visualbasicscript.com/m_45440/tm.htm
2.  http://www.visualbasicscript.com/m_40908/tm.htm

Function - Return Multiple Values; How to return multiple values?
1.  One method would be to use an array.

      
2.  Another method would be to use a dictionary to return the values...making it easier to reference the values when you need to use them.

      

Get Additional File Info
1. 


      

Get Local or Remote User Name
1.
  Local UserName using WSHNetwork

      
2.  Local UserName using ADSystemInfo; useful if you intend to bind to the users AD object

      
3.  Local or Remote UserName using WMI and Win32_ComputerSystem class; a period "." indicates the local PC

      
4.  Local or Remote UserName using WMI and Win32_Process; determine user by looking at the explorer.exe process
and more reliable than #3 above.

      

Get OS/SP Version, Disable/Enable IE Check Zone, Compare File Version, Delete File/Folder
1.  Check out mbouchard's post:  http://www.visualbasicscript.com/m_57816/tm.htm

Login Script
1.  Map Drives - XML Based:  http://www.visualbasicscript.com/m_52191/tm.htm

Read a File Into an Array
1.  ehvbs posted a method here: http://www.visualbasicscript.com/m_47020/tm.htm
2.  A simple method...
NOTE:  This method does not take into consideration any unnecessary blank spaces at the end of you file so you may get empty array elements!

      
3.  Read a File to an Array using Regular Expressions to remove preceeding/trailing blank lines

      

Get Web Content
1.  http://www.microsoft.com/technet/scriptcenter/scripts/misc/intnet/msitvb01.mspx

How can I find a computer a user is logged into? Find logged in user.
The short answer is there is no easy way to get this info. See the link below for a discussion on this same question.
1.  http://www.visualbasicscript.com/m_42096/mpage_1/tm.htm

How can I force my script to run in CScript?
1.  Based off a post by mbouchard.

      

How can I generate a random number?
1.  http://www.visualbasicscript.com/m_46705/tm.htm
2.  http://www.microsoft.com/technet/technetmag/issues/2007/01/HeyScriptingGuy/default.aspx (towards the end of the article)

How can I get a folders file count?  Folder Recursion
1.  This would be one way.

      
2.  ehvbs additions to the code above: 
http://www.visualbasicscript.com/m_49006/tm.htm
3.  Basic folder recursion, recurse folder, enumerate files and folders

      
4.  This is an example of recursing through a folder and searching for specific file extensions and returning their path and datelastmodified

      
5.  This is a very neat way to search using dir.exe (which is extremely fast):
http://www.visualbasicscript.com/m_47844/tm.htm
6.  This is not necessarily file count but it deals with Files and Folders using FSO:
http://www.microsoft.com/technet/scriptcenter/resources/begin/ss0507.mspx
7.  Recurse a folder X number of directories deep.

      
8.  Recursive Delete Files/SubFolders
FSO Method1

      

FSO Method2

      

WMI Version

      

How can I get the input from an HTML back to my VBScript?
1.  Tom Lavedas shows the following example
http://members.cox.net/tglbatch/wsh/PasswordBox.vbs.txt

      

How can I pause an HTA? What can I use in an HTA instead of WScript.Sleep?

There are a few things you can try an use.
1.  window.setInterval("FunctionorSubName", 1000) ' the 1000 is 1 second
2.  window.setTimeout("FunctionorSubName", 1000)
3.  Another method would be to create a Sub to pause for us.

      
4.  Another method would be to call an external .vbs file that takes as an argument the sleep time

      

How can I sort my array?
1.  Component by TNO that has array related functions (including sort):  http://www.visualbasicscript.com/fb.aspx?m=59479
2. 
http://www.microsoft.com/technet/technetmag/issues/2007/01/HeyScriptingGuy/default.aspx (Bubble Sort & .Net Array Sort)

How do I get an applications uninstall string from the registry?
1. 
One way would be to enumerate the subkeys in the registry under HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall

      

How do I make my script wait for a process to terminate?

1.  One way would be using WMI and the Win32_Process Class

      

HTA Dynamicically Populate a drop down
1.  http://www.visualbasicscript.com/m_47106/tm.htm

MD5 Checksum
1.  Free COM dll:  http://www.xstandard.com/en/downloads/

Ping
1.  http://www.visualbasicscript.com/m_42535/tm.htm

Progress Bar
Found these post by searching for the word "Progress"
1.  http://www.visualbasicscript.com/m_32390/tm.htm
2.  http://www.visualbasicscript.com/m_40601/tm.htm
3.  http://www.visualbasicscript.com/m_41561/tm.htm
4.  http://www.visualbasicscript.com/m_24746/tm.htm
5.  http://www.visualbasicscript.com/m_47750/tm.htm
6.  http://www.microsoft.com/technet/scriptcenter/scripts/misc/progress/default.mspx

Accessing SQL, MS Access, MS Excel using ADO
1.  SQL Ref -  http://www.w3schools.com/sql/sql_quickref.asp
2.  SQL/Access -  http://www.microsoft.com/technet/scriptcenter/scripts/misc/database/default.mspx
3.  MS Access -  http://www.microsoft.com/technet/scriptcenter/resources/officetips/nov05/tips1103.mspx
4.  MS Excel -  http://www.microsoft.com/technet/scriptcenter/resources/officetips/jun05/tips0607.mspx
5.  Connection Strings -  http://www.connectionstrings.com/
6.  SQL Syntax -  http://www.devguru.com/Technologies/sqlsyntax/quickref/sql_syntax_intro.html
7.  Here is a simple example accessing an Access .mdb

      

Registry
1.  http://www.visualbasicscript.com/m_31698/mpage_1/key_stdregprov/tm.htm#32023
2.  Set wallpaper for ALL users
http://www.visualbasicscript.com/m_47074/tm.htm
3.  Set registry value for ALL users (based on the code in the link above)
http://www.visualbasicscript.com/m_51805/tm.htm

Regular Expressions; RegExp, RegEx
1. 
http://www.ilovejackdaniels.com/regular_expressions_cheat_sheet.pdf
2.  http://msdn2.microsoft.com/en-us/library/yab2dx62.aspx
3.  http://www.regular-expressions.info/
4.  http://regexlib.com/default.aspx

Telnet
1.  http://www.visualbasicscript.com/m_38306/tm.htm

VBS to EXE; Convert .vbs to .exe; convert vbscript to executable
1.  http://www.visualbasicscript.com/m_29193/tm.htm

Wait for a process to become idle for a certain amount of time in seconds
Based off a post by morpheus83uk
1.  http://www.visualbasicscript.com/m_46514/tm.htm

      

Why doesn't this objShell.Run "C:\Program Files\Adobe\Reader 8.0\Reader\AcroRd32.exe" work??
Well the reason for this is the empty spaces in the path.  A solution is to add the additional quotes.
1.  EBGreen posted a function similar to the one below that works great.

      
2.  You could also use double quotes, but that can start getting confusing

      

Zip Files
1.  http://www.visualbasicscript.com/m_46632/tm.htm
2.  See files inside a ZIP file (tested on WinXP)...figured it was possible from the link directly above.

      

< Message edited by dm_4ever -- 4/24/2008 7:23:27 AM >


_____________________________

dm_4ever

My philosophy: K.I.S.S - Keep It Simple Stupid
Read Me: http://www.visualbasicscript.com/m_24727/tm.htm
Frequently Asked Stuff: http://www.visualbasicscript.com/m_47117/tm.htm
 
 
Revisions: 18 | 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 >> Frequently Asked Stuff 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