Hopefully "ScriptingTipsAndTricks" helps you with your batch file or vbscript scripting :-)
[Bottom][Contents][Prev]: LPad0() - Pad a value with zeros but never truncate[Next]: RestartCscriptIn32BitModeIfRequired() - if in 64 bit mode
\->VBSCRIPT Files->MkObject() - Create COM Object with Error Checking

[anchor]

The Code for: "MkObject() [Create COM Object with Error Checking].vbs.txt"

This is the example, a shortcut was installed to this code :

'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
' $Header:   C:/DBAREIS/Projects.PVCS/Win32/ScriptingTipsAndTricks/EXAMPLE[vbs].MkObject() [Create COM Object with Error Checking].vbs.txt.pvcs   1.0   29 Jun 2014 12:51:22   USER "Dennis"  $
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
...

dim oShell : set oShell = MkObject("WScript.Shell")
dim oFS    : set oFS    = MkObject("Scripting.FileSystemObject")

...
set oShell = Nothing
set oFS    = Nothing




'=========================================================================
function MkObject(ByVal AutomationClass)                'Version 14.152a
'=========================================================================
    on error resume next
    set MkObject = wscript.CreateObject(AutomationClass)
    VbsCheck "Loading the automation class """ & AutomationClass & """." & " Reason 0x" & hex(err.number) & " - " & err.description
end function


'============================================================================
sub VbsCheck(ByVal DoingText)
'============================================================================
    if  err.number <> 0 then
        Die "FAILED: " & DoingText & " Reason 0x" & hex(err.number) & " - " & err.description
    end if
end sub


Microsoft awarded me an MVP (Most Valuable Professional award) in 2004, 2005, 2006, 2007, 2008 & 2009 for the Windows SDK (Windows Installer) area.Please email me any feedback, additional information or corrections.
See this page online (look for updates)

[Top][Contents][Prev]: LPad0() - Pad a value with zeros but never truncate[Next]: RestartCscriptIn32BitModeIfRequired() - if in 64 bit mode


ScriptingTipsAndTricks© is (C)opyright Dennis Bareis 2003-2008 (All rights reserved).
Sunday September 07 2014 at 12:50pm
Visit ScriptingTipsAndTricks's Home Page
Microsoft awarded me an MVP (Most Valuable Professional award) in 2004, 2005, 2006, 2007, 2008 & 2009 for the Windows SDK (Windows Installer) area.