Announcement

Collapse
No announcement yet.

Powershell into VBS?

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Powershell into VBS?

    Is this possible without doing it by hand?

    If so, what/what kind of tool can I use?

    I've got a ps1 script to remove anything in "add/remove'' with "Toolbar" in it's name.

    It's a Powershell script which I want into VBS since our machines don't have PS on them.

    Any help would really be appreciated.
    "To err is human but to really **** things up requires a computer user..."

    "The path to enlightenment is /user/bin/enlightenment"

    A+ CE

  • #2
    Re: Powershell into VBS?

    I am not aware of any tool. Most of the time people do ask the other way around.

    Post the script here and we'll take a look. Things like WMI calls can be done with VBS just fine.

    -vP

    Comment


    • #3
      Re: Powershell into VBS?

      Yea I saw a ton on VBS to Powershell and we're thinking of implementing PS into future releases of our image, but we aren't sure yet.


      Code:
          #***********************************************************************
          # "Uninstall-Toolbars.ps1"
          #
          # Written by Aaron Wurthmann (aaron <AT> wurthmann <DOT> com)
          #
          # If you edit please keep my name as an original author and
          # keep me apprised of the changes, see email address above.
          # You the executor,runner,user accept all liability.
          # This code comes with ABSOLUTELY NO WARRANTY.
          # You may redistribute copies of the code under the terms of the GPL v2.
          # -----------------------------------------------------------------------
          # Prerequisite:
          # Should work with both PowerShell v1 and v2. I wrote and tested it on XP
          # as well was Windows 7 x64. Make sure to have your execution mode is set
          # properly. PSH> get-help about_Execution_Policies
          # In addition, WASP, Windows Automation Snapin for PowerShell, was used
          # for the macros to run and click items as needed, it is not mandatory.
          # -----------------------------------------------------------------------
          # 2010.03.15 ver 1.2
          #
          # Summary:
          # Removes software based on display name shown in "Add Remove Programs".
          # In the majority of cases it just runs whatever uninstall program the
          # program claims will uninstall itself. In a few cases a macro is run.
          # See $apps array section and comments to add to the list of programs.
          #
          # Known Bugs:
          # At this time I have noticed an issue with the "Bing Bar" attemping to
          # re-install itself. Actually what is happening is a related install
          # 'Bing Bar Platform' is being launched and as a result it asks if you
          # want to reinstall. I haven't looked into solving this just yet. My advice
          # at the moment is... don't reinstall it. *laugh*
          #************************************************************************
           
          #Function Section - Dont Touch, unless you Know what you are doing.
          function Get-AppInfo {
              Param([string]$filter)
              $regkey=Get-Item "HKLM:SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"
              $SubKeyNames = $regkey.GetSubKeyNames()
              foreach($SubKeyName in $SubKeyNames){
                  $SubKeyString="$regkey\$SubKeyName" -replace "HKEY_LOCAL_MACHINE\\","HKLM:"
                  $SubKey=Get-Item $SubKeyString
                  $DisplayName=$SubKey.GetValue('DisplayName')
                  If ($DisplayName -like "*$filter*"){
                      $DisplayName
                      $SubKey.GetValue('UninstallString')
                  }
              }
          }
           
          function Remove-MSI {
              Param([string]$uninstallString)
              Stop-Webbrowser
              $uninstall=$uninstallString.Replace('/I','/X')
              $uninstallCmd=$uninstall.split(' ')[0]
              $uninstallParam=$uninstall.split(' ')[1]
              & $uninstallCmd $uninstallParam /qn
          }
           
          function Remove-Install {
              Param([string]$uninstallString)
              Stop-Webbrowser
              $uninstallCmd=$UninstallString.split('"')[1]
              if ($uninstallCmd){
                  $uninstallCmd=$uninstallCmd.Trim()
                  $uninstallParam=$UninstallString.split('"')[2]
                  if ($uninstallParam){
                      $uninstallParam=$uninstallParam.Trim()
                  }
              }
              ELSE{
                  $uninstallCmd=$UninstallString.split('/')[0].Trim()
                  $uninstallParam=$UninstallString.split('/')[1]
                  if ($uninstallParam){
                      $uninstallParam='/' +$uninstallParam.Trim()
                  }
              }
           
              & $uninstallCmd $uninstallParam
          }
           
          function Stop-Webbrowser {
              Get-Process | Where {$_.Name -eq "iexplore"} | kill
              #Get-Process | Where {$_.Name -eq "firefox"} | kill
          }
           
          function Remove-AltavistaToolbar {
              Param([string]$uninstallString)
              Stop-Webbrowser
              & $UninstallString.split('/')[0]
              Add-PSSnapin WASP -ea "SilentlyContinue"
              Select-Window > $nul
              if ($? -eq $True){
                  Start-Sleep 1
                  Select-Window uninstall | Send-Keys "y"
                  Start-Sleep 1
                  Stop-Webbrowser
              }
              ELSE{
                  Remove-Install $UninstallString
              }
          }
           
          function Remove-BingBar {
              Param([string]$uninstallString)
              Stop-Webbrowser
              & $UninstallString.split('/')[0]
              Add-PSSnapin WASP -ea "SilentlyContinue"
              Select-Window > $nul
              if ($? -eq $True){
                  Start-Sleep 1
                  Select-Window InstallManager | Send-Keys "{TAB}","{ENTER}"
                  Stop-Webbrowser
              }
              ELSE{
                  Remove-Install $UninstallString
              }
          }
           
          function Remove-Yahoo!Toolbar {
              Param([string]$uninstallString)
              Stop-Webbrowser
              & $UninstallString.split('/')[0]
              Add-PSSnapin WASP -ea "SilentlyContinue"
              Select-Window > $nul
              if ($? -eq $True){
                  Start-Sleep 1
                  Select-Window UNYT_W~1 | Send-Keys "y"
                  Start-Sleep 2
                  Select-Window BU_ | Select-ChildWindow | Send-Keys "n"
                  Start-Sleep 1
                  Select-Window BU_ | Send-Keys "c"
                  Start-Sleep 1
                  Stop-Webbrowser
              }
              ELSE{
                  Remove-Install $UninstallString
              }
          }
          #End Fuction Section
           
          #    Add Apps here that you want to remove. Use the exact name as it appears in "Add Remove Programs"
          #    For all toolbars uncomment 'Toolbar' and remove all other toolbars except 'Bing Bar'
          [email protected](
              'Bing Bar',
              'Toolbar';
          )
           
          #These apps have extra routines, so there are custom functions.
          #WASP, Windows Automation Snapin for PowerShell, is required for macros to run
          [email protected](
              'Altavista Toolbar',
              'Bing Bar',
              'Yahoo! Toolbar';
          )
          #End Editable Section
           
          #Main
          if ($apps){
              foreach($app in $apps){
                  $AppInfo=(Get-AppInfo $app)
                  $DisplayName=$AppInfo[0]
                  $UninstallString=$AppInfo[1]
                  if ($UninstallString -like "*MsiExec*"){
                      Remove-MSI $UninstallString
                  }
                  Else{
                      if ($macroapps -contains $DisplayName){
                          $cutomRemove='Remove-' + $DisplayName.Replace(' ','')
                          & $cutomRemove
                      }
                      ELSE{
                          Remove-Install $UninstallString
                      }
                  }
              }
          }
      "To err is human but to really **** things up requires a computer user..."

      "The path to enlightenment is /user/bin/enlightenment"

      A+ CE

      Comment


      • #4
        Re: Powershell into VBS?

        Isn't it much easier to deploy Powershell to your clients using WSUS?
        Marcel
        Technical Consultant
        Netherlands
        http://www.phetios.com
        http://blog.nessus.nl

        MCITP(EA, SA), MCSA/E 2003:Security, CCNA, SNAF, DCUCI, CCSA/E/E+ (R60), VCP4/5, NCDA, NCIE - SAN, NCIE - BR, EMCPE
        "No matter how secure, there is always the human factor."

        "Enjoy life today, tomorrow may never come."
        "If you're going through hell, keep going. ~Winston Churchill"

        Comment


        • #5
          Re: Powershell into VBS?

          Given as NONE(We are in Ga, and only one of our 115+sites(totaling over 180 computers) is even in the same state of us) of the ones we want are on our domain, no.

          I have it sitting in "C:\PShellRemoInstall\" using LogMeIn's "One2Many" to deploy it, but first I have to figure out how to silently install the .exe(from the back end without us having to log on to the system)

          So far /quiet doesn't want to work for me so I'm going to try /passive now
          Attached Files
          Last edited by Managor; 10th November 2010, 16:52.
          "To err is human but to really **** things up requires a computer user..."

          "The path to enlightenment is /user/bin/enlightenment"

          A+ CE

          Comment


          • #6
            Re: Powershell into VBS?

            Oh boy, that script isn't too hard to translate, but it'll take some time.

            To give a brief outline about what it does is as follows.

            It looks for application uninstall strings from registry:
            HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uni nstall

            Then it looks each uninstall key for subkey value Displayname. If it finds displayname Tool bar or Bingbar, it'll return its uninstall string.

            If the uninstall string contains msiexec, it simply launches msiexec with appropriate switches that uninstall the toolbar.

            For Altavista, Yahoo and Bing, it uses WASP (that's something like AutoIT for Powershell, so you can send mouse/key actions to windows. Not familiar for me) to send a click to remove button. The uninstall actions seem to depend on the toolbar type, looks like the Yahoo bar uninstaller is asking questions that need to be answered.

            To sum up, most of the stuff is trivial with VBScript and the rest are possible as well. Even sending keyboard commands is possible if not a bit cubersome.

            -vP

            Comment

            Working...
            X