Ok, noch mal Danke. Das hat mir alles sehr weiter geholfen und ich hab jetzt mal ein Paket für Windows 7, 64-bit gebaut mit welchem ich den Treiber, den Port und auch den Drucker anlegen kann.
Das funktioniert auch alles.
Genauso hab ich gleich noch eine Deinstallationsroute dazu gebaut welches auch alle drei Teile sauber aus dem System entfernt. Die Deinstallationsroutine an sich funktioniert auch, allerdings habe ich Probleme damit zu prüfen ob es den Drucker bereits gibt....
Um den Rückgabewert von Powershell auszulesen habe ich mich dem Beispiel von hier bedient
http://download.uib.de/opsi4.0/doc/html ... t-execwith
bzw. heisst es weiter unten, dass es funktionieren sollte wie bei dem Beispiel von execpython_hello.
Code: Alles auswählen
DefStringList pythonresult
Set pythonResult = GetOutStreamFromSection('execpython_hello -a "opt a“')
Wenn ich das allerdings so einbaue
Code: Alles auswählen
DefStringList $IsInstalled$
Set $IsInstalled$ = GetOutStreamFromSection('ExecWith_getPrinter "%System%\WindowsPowerShell\v1.0\powershell.exe" -command WINST /64Bit')
[ExecWith_getPrinter]
(Get-WmiObject Win32_Printer -Filter "Name='$NameOfInstance$'").PrinterStatus
Dann krieg ich beim Ausführen die Fehlermeldung
Code: Alles auswählen
Section Sub "P:\printerkonicasmall\delsub3264.ins" (Command in line 8):
$IsInstalled$ = GetOutStreamFromSection('ExecWith_getPrinter "C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe" -command WINST /64Bit')
Section "ExecWith_getPrinter" not found
Führe ich das ExecWith einfach nur aus funktioniert es, aber ich brauch natürlich den Rückgabewert um die Entscheidung treffen zu können ob deinstalliert werden soll.
Code: Alles auswählen
ExecWith_getPrinter "%System%\WindowsPowerShell\v1.0\powershell.exe" -command WINST /64Bit
[ExecWith_getPrinter]
(Get-WmiObject Win32_Printer -Filter "Name='$NameOfInstance$'").PrinterStatus
Vielleicht hat ja noch jemand eine Idee, weil im Moment hängt es eigentlich nur noch daran. Alles andere funktioniert, daher hier schon mal die Skripte:
setup.ins
Code: Alles auswählen
; Copyright (c) uib gmbh (www.uib.de)
; This sourcecode is owned by uib
; and published under the Terms of the General Public License.
; credits: http://www.opsi.org/en/credits/
[Actions]
requiredWinstVersion >= "4.11.2.6"
DefVar $LogDir$
DefVar $ProductId$
DefVar $MinimumSpace$
DefVar $INST_SystemType$
DefVar $INST_architecture$
DefVar $NameOfInstance$
DefVar $DriverName$
DefVar $DriverPath$
DefVar $PortIp$
DefStringList $IsInstalled$
DefVar $test$
Set $INST_SystemType$ = GetSystemType
set $INST_architecture$ = GetProductProperty("install_architecture","system specific")
Set $LogDir$ = "%SystemDrive%\tmp"
; ----------------------------------------------------------------
; - Please edit the following values -
; ----------------------------------------------------------------
Set $ProductId$ = "printerKonicaSmall"
Set $MinimumSpace$ = "50 MB"
; the path were we find the product after the installation
Set $NameOfInstance$ = "Kopierer klein"
Set $DriverName$ = "KONICA MINOLTA C360SeriesPCL"
Set $DriverPath$ = "%Scriptpath%\KonicaSmall\KOAZ8J__.INF"
Set $PortIp$ = "xxx.xxx.xxx.xxx"
; ----------------------------------------------------------------
if not(HasMinimumSpace ("%SystemDrive%", $MinimumSpace$))
LogError "Not enough space on %SystemDrive%, " + $MinimumSpace$ + " on drive %SystemDrive% needed for " + $ProductId$
isFatalError
; Stop process and set installation status to failed
else
comment "Show product picture"
ShowBitmap "%ScriptPath%\" + $ProductId$ + ".png" $ProductId$
if FileExists("%ScriptPath%\delsub3264.ins")
comment "Start uninstall sub section"
Sub "%ScriptPath%\delsub3264.ins"
endif
comment "installing"
if ($INST_SystemType$ = "64 Bit System") and (($INST_architecture$ = "system specific") or ($INST_architecture$ = "both") or ($INST_architecture$ = "64 only"))
Message "Installing " + $ProductId$ + " 64 Bit..."
comment "Patch registry to allow local powershell scripts...."
Registry_patch /64Bit
comment "Installing driver...."
DosInAnIcon_Treiber
comment "Installing printer port...."
comment $PowerShellPath$
ExecWith_setPort "%System%\WindowsPowerShell\v1.0\powershell.exe" -command WINST /64Bit
comment "Installing printer...."
ExecWith_setPrinter "%System%\WindowsPowerShell\v1.0\powershell.exe" -command WINST /64Bit
comment "Patch registry to disallow local powershell scripts...."
Registry_unpatch /64Bit
endif
endif
[Registry_patch]
openkey [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell]
set "ExecutionPolicy" = "RemoteSigned"
[Registry_unpatch]
openkey [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell]
set "ExecutionPolicy" = "Restricted"
[DosInAnIcon_Treiber]
rundll32 printui.dll,PrintUIEntry /ia /m "$DriverName$" /h "x64" /v "Typ 3 - Benutzermodus" /f $DriverPath$
[ExecWith_setPort]
Write-Output "Creating printer port `"$NameOfInstance$`""
$port =([WMICLASS]"\\.\ROOT\cimv2:Win32_TCPIPPrinterPort").createInstance()
$port.Name="$NameOfInstance$"
$port.SNMPEnabled=$false
$port.Protocol=1
$port.HostAddress="$PortIp$"
$port.Put()
[ExecWith_setPrinter]
Write-Output "Creating printer `"$NameOfInstance$`""
$printer =([WMICLASS]"\\.\ROOT\cimv2:Win32_Printer").createInstance()
$printer.Name="$NameOfInstance$"
$printer.DriverName="$DriverName$"
$printer.DeviceID="$NameOfInstance$"
$printer.PortName="$NameOfInstance$"
$printer.Put()
uninstall.ins
Code: Alles auswählen
; Copyright (c) uib gmbh (www.uib.de)
; This sourcecode is owned by uib gmbh
; and published under the Terms of the General Public License.
; credits: http://www.opsi.org/en/credits/
[Actions]
requiredWinstVersion >= "4.11.2.6"
DefVar $LogDir$
DefVar $ProductId$
DefVar $MinimumSpace$
DefVar $INST_SystemType$
DefVar $INST_architecture$
DefVar $NameOfInstance$
DefVar $DriverName$
DefVar $DriverPath$
DefVar $PortIp$
DefStringList $IsInstalled$
DefVar $test$
Set $INST_SystemType$ = GetSystemType
set $INST_architecture$ = GetProductProperty("install_architecture","system specific")
Set $LogDir$ = "%SystemDrive%\tmp"
; ----------------------------------------------------------------
; - Please edit the following values -
; ----------------------------------------------------------------
Set $ProductId$ = "printerKonicaSmall"
Set $MinimumSpace$ = "50 MB"
; the path were we find the product after the installation
Set $NameOfInstance$ = "Kopierer klein"
Set $DriverName$ = "KONICA MINOLTA C360SeriesPCL"
Set $DriverPath$ = "%Scriptpath%\KonicaSmall\KOAZ8J__.INF"
Set $PortIp$ = "xxx.xxx.xxx.xxx"
; ----------------------------------------------------------------
comment "Show product picture"
ShowBitmap "%ScriptPath%\" + $ProductId$ + ".png" $ProductId$
Message "Uninstalling " + $ProductId$ + " ..."
if FileExists("%ScriptPath%\delsub3264.ins")
comment "Start uninstall sub section"
Sub "%ScriptPath%\delsub3264.ins"
endif
delsub3264.ins
Code: Alles auswählen
; Copyright (c) uib gmbh (www.uib.de)
; This sourcecode is owned by uib gmbh
; and published under the Terms of the General Public License.
; credits: http://www.opsi.org/en/credits/
comment "Patch registry to allow local powershell scripts...."
Registry_patch /64Bit
;Set $IsInstalled$ = GetOutStreamFromSection('ExecWith_getPrinter "%System%\WindowsPowerShell\v1.0\powershell.exe" -command WINST /64Bit')
ExecWith_getPrinter "%System%\WindowsPowerShell\v1.0\powershell.exe" -command WINST /64Bit
comment "Patch registry to disallow local powershell scripts...."
Registry_unpatch /64Bit
Set $test$ = takeString(0,$IsInstalled$)
Set $test$ = "3"
if ($INST_SystemType$ = "64 Bit System") and (($INST_architecture$ = "system specific") or ($INST_architecture$ = "both") or ($INST_architecture$ = "64 only"))
Message "Uninstalling " + $ProductId$ + " 64 Bit..."
if ($test$ = "3")
comment "Uninstall printer...."
comment $test$
comment "Patch registry to allow local powershell scripts...."
Registry_patch /64Bit
comment "Remove printer...."
ExecWith_deletePrinter "%System%\WindowsPowerShell\v1.0\powershell.exe" -command WINST /64Bit
comment "Remove port...."
ExecWith_deletePort "%System%\WindowsPowerShell\v1.0\powershell.exe" -command WINST /64Bit
comment "Remove driver...."
DosInAnIcon_Treiber
comment "Patch registry to disallow local powershell scripts...."
Registry_unpatch /64Bit
else
comment "Printer not found...."
endif
endif
[ExecWith_getPrinter]
(Get-WmiObject Win32_Printer -Filter "Name='$NameOfInstance$'").PrinterStatus
[ExecWith_deletePrinter]
$printer = Get-WmiObject Win32_Printer -Filter "Name='$NameOfInstance$'"
$printer.delete()
[ExecWith_deletePort]
$port = Get-WmiObject Win32_TCPIPPrinterPort -Filter "Name='$NameOfInstance$'"
$port.delete()
[DosInAnIcon_Treiber]
rundll32 printui.dll,PrintUIEntry /dd /m "$DriverName$" /h "x64" /v "Typ 3 - Benutzermodus"
[Registry_patch]
openkey [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell]
set "ExecutionPolicy" = "RemoteSigned"
[Registry_unpatch]
openkey [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell]
set "ExecutionPolicy" = "Restricted"