Übersicht

Das Active Setup Advanced ist eine verbesserte Möglichkeit, um Benutzerteile auszuführen.

 

Parameter

DescriptionMicrosoft Office FixBeschreibung der Software
Command"C:\Program Files\simplewall\ActiveSetup.vbs"Kommando, der mit Benutzerrechten ausgeführt wird
ReferenceFileC:\Program Files\simplewall\simplewall.exeDiese Datei muss existieren, damit der Command ausgeführt wird
ReferenceRegHKEY_LOCAL_MACHINE\SOFTWARE\SimpleWallDieser Registry Key muss existieren, damit der Command ausgeführt wird
Typeinstall/uninstallDer Command muss nach der Installation/Deinstallation ausgeführt werden

 

Script


# 1.0 Initial Version by Cluebiz

# Copy this file to c:\Program Files\cluebiz\Active Setup Advanced\RunActivesetup.ps1
# Create a key "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", name "Active Setup Advanced", value "c:\Program Files\cluebiz\Active Setup Advanced\RunActivesetup.ps1"

$key = Get-ChildItem -path "HKLM:\SOFTWARE\Microsoft\Active Setup Advanced"

foreach($mykey in $key)
{
   $machineactivesetupkey = $mykey.Name.Replace("HKEY_LOCAL_MACHINE\","HKLM:\")
   $useractivesetupkey    = $mykey.Name.Replace("HKEY_LOCAL_MACHINE\","HKCU:\")
   $machinedescription = ""
   $userdescription = ""
   $machinereferencefile = ""
   $machinecommand = ""
   $machinetype = ""
   try {
    $machinedescription = Get-ItemPropertyValue -Path $machineactivesetupkey -Name "Description" -ErrorAction Ignore
   } catch { }
   try {
    $userdescription = Get-ItemPropertyValue -Path $useractivesetupkey -Name "Description" -ErrorAction Ignore
   } catch { }
   try {
    $userdescription = Get-ItemPropertyValue -Path $useractivesetupkey -Name "Description" -ErrorAction Ignore
   } catch { }
   try {
    $machinecommand = Get-ItemPropertyValue -Path $machineactivesetupkey -Name "Command" -ErrorAction Ignore
   } catch { }
   try {
    $machinereferencefile = Get-ItemPropertyValue -Path $machineactivesetupkey -Name "ReferenceFile" -ErrorAction Ignore
   } catch { }
   try {
    $machinereferencereg = Get-ItemPropertyValue -Path $machineactivesetupkey -Name "ReferenceReg" -ErrorAction Ignore
   } catch { }
   try {
    $machinetype = Get-ItemPropertyValue -Path $machineactivesetupkey -Name "Type" -ErrorAction Ignore
   } catch { }

   # handle install
   if($machinetype -eq "install")
   {
       if($userdescription -ne $machinedescription)
       {

            #check if valid
            $isvalid = $true
            if($machinereferencefile -ne "")
            {
                try {
                if(Test-Path $machinereferencefile)
                {
                    #ok
                }
                else
                {
                    $isvalid = $false
                }
                } catch { }

            }
             if($machinereferencereg -ne "")
            {
                $testreg = $machinereferencereg.Replace("HKEY_LOCAL_MACHINE\","HKLM:\")
                $testreg = $testreg.Replace("HKLM\","HKLM:\")
                try {
                if(Test-Path $testreg)
                {
                    #ok
                }
                else
                {
                    $isvalid = $false
                }
                } catch { }

            }

            if($isvalid)
            {

                try {
                Start-Process $machinecommand -Wait -WindowStyle Hidden
                } catch { }

                try {
                New-Item -Path "HKCU:\SOFTWARE\Microsoft\Active Setup Advanced" -Force
                }
                catch { }
                try {
                New-Item -Path $useractivesetupkey -Force
                } catch { }

                $userdate = Get-Date -Format "yyyy-MM-ddTHH:mm:ss"

                try {
                New-ItemProperty  -Path $useractivesetupkey -Name "Description" -Value $machinedescription
                } catch { }

                try {
                New-ItemProperty  -Path $useractivesetupkey -Name "DateTime" -Value $userdate
                } catch { }

            }
       }
   }

   # handle uninstall
   if($machinetype -eq "uninstall")
   {
       if($userdescription -ne $machinedescription)
       {
            $isvalid = $true
            if($isvalid)
            {
                try {
                Start-Process $machinecommand -Wait -WindowStyle Hidden
                } catch { }

                try {
                New-Item -Path "HKCU:\SOFTWARE\Microsoft\Active Setup Advanced" -Force
                }
                catch { }
                try {
                New-Item -Path $useractivesetupkey -Force
                } catch { }

                $userdate = Get-Date -Format "yyyy-MM-ddTHH:mm:ss"

                try {
                New-ItemProperty  -Path $useractivesetupkey -Name "Description" -Value $machinedescription
                } catch { }

                try {
                New-ItemProperty  -Path $useractivesetupkey -Name "DateTime" -Value $userdate
                } catch { }
            }
       }
    }

}