code_junkie

How do you access a custom .net dll in vbscript?

Nov 12th, 2011
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. regasm your.dll /codebase
  2.  
  3. $a = New-Object -comobject Your.Utils.Logging
  4. $a.WriteError2("Application", "hello",1,1)
  5.  
  6. Set logger = CreateObject("Your.Utils.Logging")
  7. logger.WriteError2 "Application", "hello from vbs",1,1
  8.  
  9. // bind a variabe to WScript.Shell
  10. Set WshShell = CreateObject("WScript.Shell")
  11.  
  12. // define the path to the regasm.exe file
  13. RegAsmPath = "c:WindowsMicrosoft.NETFrameworkv2.0.50727RegAsm.exe"
  14.  
  15. // register the dll
  16. WshShell.run "cmd /c " & RegAsmPath & " c:tempcbsecurity.dll /codebase /nologo /s", 0, True
  17.  
  18. // bind a variable to the dll
  19. Set cbUtil = CreateObject("CBSecurity.Utilities")
  20.  
  21. Public Function IsAlive() As Boolean
  22. Return True
  23. End Function
  24.  
  25. //check if dll is available to your code
  26. msgbox "cbUtil is alive: " & cbUtil.IsAlive
Add Comment
Please, Sign In to add comment