Guest User

Untitled

a guest
Jan 16th, 2018
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.52 KB | None | 0 0
  1. Option Explicit
  2.  
  3. Dim oShell, WshShell, Title, strInputIU, strInputPATH, executeString, objShell, strCurrentDir, result, filesys
  4. Set WshShell = WScript.CreateObject("WScript.Shell")
  5. Set objShell = CreateObject("WScript.shell")
  6. Set filesys = CreateObject("Scripting.FileSystemObject")
  7. strCurrentDir = objShell.CurrentDirectory
  8.  
  9. If WScript.Arguments.Named.Exists("elevated") = False Then
  10. CreateObject("Shell.Application").ShellExecute "wscript.exe", """" & WScript.ScriptFullName & """ /elevated", "", "runas", 1
  11. WScript.Quit
  12. Else
  13. Set oShell = CreateObject("WScript.Shell")
  14. oShell.CurrentDirectory = CreateObject("Scripting.FileSystemObject").GetParentFolderName(WScript.ScriptFullName)
  15. End If
  16.  
  17. Title = "Windows Service Installer by Luke Wyatt"
  18. executeString = "@echo off & cd \ & cd C:\Windows\Microsoft.NET\Framework\v2.0.50727"
  19.  
  20. strInputIU = InputBox( "If you would like to install a service, type I. If you are trying to uninstall a service, type U.", Title )
  21.  
  22. result = MsgBox("Would you like to load the path from the save file?", VBYesNo, Title)
  23. If (result = VBYes) Then
  24. Set objShell = CreateObject("WScript.shell")
  25. strCurrentDir = objShell.CurrentDirectory
  26. strInputPATH = readFile(strCurrentDir & "\path.txt")
  27. Else
  28. strInputPATH = InputBox( "Enter the file location of the Windows Service Executable that you are trying to install or uninstall:", Title )
  29. End If
  30.  
  31. If filesys.FileExists(strInputPATH) Then
  32. 'DO NOTHING
  33. Else
  34. WScript.echo "The file path given does not exist or cannot be reached: Application closing."
  35. WScript.quit
  36. End if
  37.  
  38. If (strInputIU = "i") or (strInputIU = "I") Then
  39. executeString = executeString & " & InstallUtil " & chr(34) & strInputPATH & chr(34)
  40. WshShell.Run("cmd /k" + executeString)
  41. ElseIf (strInputIU = "u") or (strInputIU = "U") Then
  42. executeString = executeString & " & InstallUtil -u " & chr(34) & strInputPATH & chr(34)
  43. WshShell.Run("cmd /k" + executeString)
  44. Else
  45. WScript.Echo "Selection was cancelled or inputted incorrectly: Application closing."
  46. WScript.quit
  47. End If
  48.  
  49. ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  50.  
  51. function readFile(sPath)
  52. const forReading = 1
  53. dim objFSO, objFile, sData
  54. set objFSO = createobject("Scripting.FileSystemObject")
  55. set objFile = objFSO.openTextFile(sPath, ForReading)
  56. sData = ""
  57. do until objFile.atEndOfStream
  58. sData = sData & objFile.readLine & vbCrLf
  59. loop
  60. objFile.close
  61. set objFile = nothing
  62. set objFSO = nothing
  63. readFile = sData
  64. end function
Add Comment
Please, Sign In to add comment