Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Apr 24th, 2012  |  syntax: None  |  size: 1.28 KB  |  hits: 24  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Get current directory and run a File in vbscript?
  2. If WScript.Arguments.length =0 Then
  3. Set objShell = CreateObject("Shell.Application")
  4.  
  5. objShell.ShellExecute "wscript.exe", Chr(34) & _
  6. WScript.ScriptFullName & Chr(34) & " uac", "", "runas", 1
  7. Else
  8. Dim intCounter, strSubkey
  9. Const HKEY_LOCAL_MACHINE = &H80000002
  10. strComputer = "."
  11.  
  12. Set objReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\" _
  13. & strComputer & "rootdefault:StdRegProv")
  14.  
  15. strKeyPath = "SOFTWAREMicrosoft"
  16.  
  17. objReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubKeys
  18.  
  19. intCounter=0
  20. For Each subkey In arrSubKeys
  21. If subkey="InetStp" Then
  22.  intCounter=1 or  strSubkey=subkey
  23. End If
  24.  
  25. Next
  26. currentDirectory = left(WScript.ScriptFullName, Len(WScript.ScriptFullName))-(len(WScript.ScriptName)))
  27.  
  28. if intCounter=0 then
  29. Set WSHShell = CreateObject("Wscript.Shell")
  30. WSHShell.Run ("currentDirectorynoiisinstalled.exe")
  31. Elseif intCounter=1 then
  32. Wscript.Echo "IIS is Already installed - " & strSubkey
  33. End If
  34. End if
  35.        
  36. dim fso: set fso = CreateObject("Scripting.FileSystemObject")
  37.  
  38. ' directory in which this script is currently running
  39. CurrentDirectory = fso.GetAbsolutePathName(".")
  40.        
  41. NewPath = fso.BuildPath(CurrentDirectory, "noiisinstalled.exe")
  42.        
  43. Set WSHShell = CreateObject("Wscript.Shell")
  44. sCurrentDirectory = WSHShell.CurrentDirectory & ""