Never been to CodeSnippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world (or not, you can keep them private!)

About this user

2 total

regsvr32 wsh

Dim objShell
Set objShell = CreateObject("WScript.Shell")
objShell.Run "regsvr32.exe c:\windows\system32\whatever.dll" 

wsh shell execute and return output

' MsgBox RunOutput("COMMAND /C DIR C:\", 0)
Function RunOutput(cProgram, nWindowType)
 
 '-- Obtain a Temporary File Name
 Dim oFS
 Set oFS = CreateObject("Scripting.FileSystemObject")
 Dim cFile
 cFile = oFS.GetSpecialFolder(2).Path & "\" & oFS.GetTempName
 
 '-- Execute the command and redirect the output to the file
 Dim oShell
 Set oShell = CreateObject("WScript.Shell")
 oShell.Run cProgram & " >" & cFile, nWindowType, True
 Set oShell = Nothing
 
 '-- Read output file and return
 Dim oFile
 Set oFile = oFS.OpenTextFile(cFile, 1, True)
 RunOutput = oFile.ReadAll()
 oFile.Close
 
 '-- Delete Temporary File
 oFS.DeleteFile cFile
 Set oFS = Nothing
 Set cFile = Nothing
 
 
End Function
2 total