Schlagwort-Archive: windows

youtube-dl aborts download of video even with retry set to infinite

I found it on stackoverflow. Here for reference a powershell loop that starts youtube-dl till it is finished without an error.
Do { .\youtube-dl.exe --all-subs --continue -R infinite https://www.bbc.co.uk/iplayer/episode/p093wpgw/cant-get-you-out-of-my-head-series-1-1-part-one-bloodshed-on-wolf-mountain } until ($?)

convert Powerpoint to JPG or PNG or whatever

I had to find an easy solution for my colleaugue to convert Powerpoint files to e.g. JPGs.
They have a big screen where they want to do slideshows and the people do Powerpoint files for easy changes.
Instead of doing all manually with save as and such it should be an automatic conversion.

Here is the batch convertPowerpoint2JPG.bat I came up with:

@echo off
SET imagemagickpath=%~dp0
set filepath=%~dp1
set extension=%~x1
set filename=%~n1
echo convert Powerpoint to PDF
if exist "%filepath%%filename%.pdf" del "%filepath%%filename%.pdf"
CSCRIPT "%imagemagickpath%ppt2pdf.vbs" "%filepath%%filename%%extension%" "%filepath%%filename%.pdf"
if not exist "%filepath%%filename%" mkdir "%filepath%%filename%"
echo convert PDF to JPGs
"%imagemagickpath%convert.exe" -monitor -quality 100 -unsharp 0x1 -density 400 "%filepath%%filename%.pdf" -resize 60%% "%filepath%%filename%\%filename%.jpg"
exit /b

It uses a vbs Skript to invoke Powerpoint for pdf saving and then converts the PDF with ImageMagick (actually the embedded portable GhostScript) to JPG.

The code for ppt2pdf.vbs is:

Option Explicit

Sub WriteLine ( strLine )
    WScript.Stdout.WriteLine strLine
End Sub

' http://msdn.microsoft.com/en-us/library/office/aa432714(v=office.12).aspx
Const msoFalse = 0   ' False.
Const msoTrue = -1   ' True.

' http://msdn.microsoft.com/en-us/library/office/bb265636(v=office.12).aspx
Const ppFixedFormatIntentScreen = 1 ' Intent is to view exported file on screen.
Const ppFixedFormatIntentPrint = 2  ' Intent is to print exported file.

' http://msdn.microsoft.com/en-us/library/office/ff746754.aspx
Const ppFixedFormatTypeXPS = 1  ' XPS format
Const ppFixedFormatTypePDF = 2  ' PDF format

' http://msdn.microsoft.com/en-us/library/office/ff744564.aspx
Const ppPrintHandoutVerticalFirst = 1   ' Slides are ordered vertically, with the first slide in the upper-left corner and the second slide below it.
Const ppPrintHandoutHorizontalFirst = 2 ' Slides are ordered horizontally, with the first slide in the upper-left corner and the second slide to the right of it.

' http://msdn.microsoft.com/en-us/library/office/ff744185.aspx
Const ppPrintOutputSlides = 1               ' Slides
Const ppPrintOutputTwoSlideHandouts = 2     ' Two Slide Handouts
Const ppPrintOutputThreeSlideHandouts = 3   ' Three Slide Handouts
Const ppPrintOutputSixSlideHandouts = 4     ' Six Slide Handouts
Const ppPrintOutputNotesPages = 5           ' Notes Pages
Const ppPrintOutputOutline = 6              ' Outline
Const ppPrintOutputBuildSlides = 7          ' Build Slides
Const ppPrintOutputFourSlideHandouts = 8    ' Four Slide Handouts
Const ppPrintOutputNineSlideHandouts = 9    ' Nine Slide Handouts
Const ppPrintOutputOneSlideHandouts = 10    ' Single Slide Handouts

' http://msdn.microsoft.com/en-us/library/office/ff745585.aspx
Const ppPrintAll = 1            ' Print all slides in the presentation.
Const ppPrintSelection = 2      ' Print a selection of slides.
Const ppPrintCurrent = 3        ' Print the current slide from the presentation.
Const ppPrintSlideRange = 4     ' Print a range of slides.
Const ppPrintNamedSlideShow = 5 ' Print a named slideshow.

' http://msdn.microsoft.com/en-us/library/office/ff744228.aspx
Const ppShowAll = 1             ' Show all.
Const ppShowNamedSlideShow = 3  ' Show named slideshow.
Const ppShowSlideRange = 2      ' Show slide range.

'
' This is the actual script
'

Dim inputFile
Dim outputFile
Dim objPPT
Dim objPresentation
Dim objPrintOptions
Dim objFso

If WScript.Arguments.Count <> 2 Then
    WriteLine "You need to specify input and output files."
    WScript.Quit
End If

inputFile = WScript.Arguments(0)
outputFile = WScript.Arguments(1)

Set objFso = CreateObject("Scripting.FileSystemObject")

If Not objFso.FileExists( inputFile ) Then
    WriteLine "Unable to find your input file " & inputFile
    WScript.Quit
End If

If objFso.FileExists( outputFile ) Then
    WriteLine "Your output file (" & outputFile & ") already exists!"
    WScript.Quit
End If

WriteLine "Input File:  " & inputFile
WriteLine "Output File: " & outputFile

Set objPPT = CreateObject( "PowerPoint.Application" )

objPPT.Visible = True
objPPT.Presentations.Open inputFile

Set objPresentation = objPPT.ActivePresentation
Set objPrintOptions = objPresentation.PrintOptions

objPrintOptions.Ranges.Add 1,objPresentation.Slides.Count
objPrintOptions.RangeType = ppShowAll

' Reference for this at http://msdn.microsoft.com/en-us/library/office/ff746080.aspx
objPresentation.ExportAsFixedFormat outputFile, ppFixedFormatTypePDF, ppFixedFormatIntentScreen, msoTrue, ppPrintHandoutHorizontalFirst, ppPrintOutputSlides, msoFalse, objPrintOptions.Ranges(1), ppPrintAll, "Slideshow Name", False, False, False, False, False

objPresentation.Close
ObjPPT.Quit

Sorry, I forgot the source. If you know it, let me know.

I used a portable version of ImageMagick and a portable version of GhostScript. You have to integrate GhostScript into ImageMagick in the file delegates.xml. Place GhostScript in ImageMagick folder and replace all appearances of gswin32c.exe with Ghostscript\bin\gswin32c.exe (if that is the path of your portable GhostScript).

Now just drag a ppt(x) file onto convertPowerpoint2JPG.bat and it creates a folder in the same directory where your ppt(x) resides and puts numbered JPGs in that folder.

You can download my example for trying it out yourself (Windows x64 version).

Einen Drucker automatisiert installieren mit einem Batch Skript

Ich wusste lange nicht, wie ich einen Drucker TCP/IP Port automatisiert erstellen konnte aber bei einem nochmaligen googeln viel mir die Lösung mit den „printing admin scripts“ auf. Nach kurzem rumprobieren kam folgendes Skript dabei raus, dass 2 gleichartige Drucker die auf verschiedenen Etagen stehen einmal mit dem Postscript und das anderemal mit einem Generic PCL Treiber installiert. Damit wollen wir es den Usern einfacher machen S/W zu drucken, ohne beim Drucker was umstellen zu müssen.

<pre>@echo off

rem pcl
SET InfPath32="\\hostname\Canon iR Adv C5030i\iR5030Win7  PCL6\32BIT\Driver\pcl6\cnp60G.inf"
SET InfPath64="\\hostname\Canon iR Adv C5030i\iR5030Win7  PCL6\x64\Driver\pcl6\cnp60Ga64.inf"
rem postscript
SET InfPath32ps="\\hostname\Canon iR Adv C5030i\iR5030 Win7 PS\32BIT\Driver\CNS30G.INF"
SET InfPath64ps="\\hostname\Canon iR Adv C5030i\iR5030 Win7 PS\x64\Driver\CNS30GA64.INF"
SET PrnName3SW="Canon S/W 3. Stock"
SET PrnName6SW="Canon S/W 6. Stock"
SET PrnName3Farbe="Canon Farbe 3. Stock"
SET PrnName6Farbe="Canon Farbe 6. Stock"
SET PrnType="Canon iR-ADV C5030/5035 PS3"
SET PrnTypePCL="Canon Generic PCL6 Driver"
SET PortIP_3_Stock=192.168.xxx.xxx
SET PortIP_6_Stock=192.168.xxx.xxx

systeminfo | find "Windows 7"
if %ERRORLEVEL% == 0 goto Win7

systeminfo | find "Windows XP"
if %ERRORLEVEL% == 0 goto WinXP

:Win7
echo Running Windows 7 Script

rem check if 32 or 64 bit
Set RegQry=HKLM\Hardware\Description\System\CentralProcessor\0
REG.exe Query %RegQry% > C:\Windows\Temp\checkOS.txt
Find /i "x86" < C:\Windows\Temp\CheckOS.txt > C:\Windows\Temp\StringCheck.txt

If %ERRORLEVEL% == 0 (
    Echo "This is 32 Bit Win7"
  rem pcl 3 stock s/w
  cscript C:\Windows\System32\Printing_Admin_Scripts\de-DE\prnport.vbs -a -r IP_%PortIP_3_Stock% -h %PortIP_3_Stock% -o RAW -n 9100
  cscript C:\Windows\System32\Printing_Admin_Scripts\de-DE\prndrvr.vbs -a -m %PrnTypePCL% -v 3 -e "Windows NT x86" -i %InfPath32%
  cscript C:\Windows\System32\Printing_Admin_Scripts\de-DE\prnmngr.vbs -a -p %PrnName3SW% -m %PrnTypePCL% -r IP_"%PortIP_3_Stock%"

  rem pcl 6 stock s/w
  cscript C:\Windows\System32\Printing_Admin_Scripts\de-DE\prnport.vbs -a -r IP_%PortIP_6_Stock% -h %PortIP_6_Stock% -o RAW -n 9100
  cscript C:\Windows\System32\Printing_Admin_Scripts\de-DE\prndrvr.vbs -a -m %PrnTypePCL% -v 3 -e "Windows NT x86" -i %InfPath32%
  cscript C:\Windows\System32\Printing_Admin_Scripts\de-DE\prnmngr.vbs -a -p %PrnName6SW% -m %PrnTypePCL% -r IP_"%PortIP_6_Stock%"

  rem postscript 3 farbe
  cscript C:\Windows\System32\Printing_Admin_Scripts\de-DE\prnport.vbs -a -r IP_%PortIP_3_Stock% -h %PortIP_3_Stock% -o RAW -n 9100
  cscript C:\Windows\System32\Printing_Admin_Scripts\de-DE\prndrvr.vbs -a -m %PrnType% -v 3 -e "Windows NT x86" -i %InfPath32ps%
  cscript C:\Windows\System32\Printing_Admin_Scripts\de-DE\prnmngr.vbs -a -p %PrnName3Farbe% -m %PrnType% -r IP_"%PortIP_3_Stock%"

  rem postscript 6 farbe
  cscript C:\Windows\System32\Printing_Admin_Scripts\de-DE\prnport.vbs -a -r IP_%PortIP_6_Stock% -h %PortIP_6_Stock% -o RAW -n 9100
  cscript C:\Windows\System32\Printing_Admin_Scripts\de-DE\prndrvr.vbs -a -m %PrnType% -v 3 -e "Windows NT x86" -i %InfPath32ps%
  cscript C:\Windows\System32\Printing_Admin_Scripts\de-DE\prnmngr.vbs -a -p %PrnName6Farbe% -m %PrnType% -r IP_"%PortIP_6_Stock%"
  ) ELSE (
    Echo "This is 64 Bit Win7"
  rem pcl 3 stock s/w
  cscript C:\Windows\System32\Printing_Admin_Scripts\de-DE\prnport.vbs -a -r IP_%PortIP_3_Stock% -h %PortIP_3_Stock% -o RAW -n 9100
  cscript C:\Windows\System32\Printing_Admin_Scripts\de-DE\prndrvr.vbs -a -m %PrnTypePCL% -v 3 -e "Windows x64" -i %InfPath64%
  cscript C:\Windows\System32\Printing_Admin_Scripts\de-DE\prnmngr.vbs -a -p %PrnName3SW% -m %PrnTypePCL% -r IP_"%PortIP_3_Stock%"

  rem pcl 6 stock s/w
  cscript C:\Windows\System32\Printing_Admin_Scripts\de-DE\prnport.vbs -a -r IP_%PortIP_6_Stock% -h %PortIP_6_Stock% -o RAW -n 9100
  cscript C:\Windows\System32\Printing_Admin_Scripts\de-DE\prndrvr.vbs -a -m %PrnTypePCL% -v 3 -e "Windows x64" -i %InfPath64%
  cscript C:\Windows\System32\Printing_Admin_Scripts\de-DE\prnmngr.vbs -a -p %PrnName6SW% -m %PrnTypePCL% -r IP_"%PortIP_6_Stock%"

  rem postscript 3 farbe
  cscript C:\Windows\System32\Printing_Admin_Scripts\de-DE\prnport.vbs -a -r IP_%PortIP_3_Stock% -h %PortIP_3_Stock% -o RAW -n 9100
  cscript C:\Windows\System32\Printing_Admin_Scripts\de-DE\prndrvr.vbs -a -m %PrnType% -v 3 -e "Windows x64" -i %InfPath64ps%
  cscript C:\Windows\System32\Printing_Admin_Scripts\de-DE\prnmngr.vbs -a -p %PrnName3Farbe% -m %PrnType% -r IP_"%PortIP_3_Stock%"

  rem postscript 6 farbe
  cscript C:\Windows\System32\Printing_Admin_Scripts\de-DE\prnport.vbs -a -r IP_%PortIP_6_Stock% -h %PortIP_6_Stock% -o RAW -n 9100
  cscript C:\Windows\System32\Printing_Admin_Scripts\de-DE\prndrvr.vbs -a -m %PrnType% -v 3 -e "Windows x64" -i %InfPath64ps%
  cscript C:\Windows\System32\Printing_Admin_Scripts\de-DE\prnmngr.vbs -a -p %PrnName6Farbe% -m %PrnType% -r IP_"%PortIP_6_Stock%")
goto exit

 

:WinXP
echo Running Windows XP Script

rem check if 32 or 64 bit
Set RegQry=HKLM\Hardware\Description\System\CentralProcessor\0
REG.exe Query %RegQry% > C:\Windows\Temp\checkOS.txt
Find /i "x86" < C:\Windows\Temp\CheckOS.txt > C:\Windows\Temp\StringCheck.txt

If %ERRORLEVEL% == 0 (
  Echo "This is 32 Bit WinXP"
  rem pcl 3 stock s/w
  cscript c:\windows\system32\prnport.vbs -a -r IP_%PortIP_3_Stock% -h %PortIP_3_Stock% -o RAW -n 9100
  cscript c:\windows\system32\prndrvr.vbs -a -m %PrnTypePCL% -v 3 -e "Windows NT x86" -i %InfPath32%
  cscript c:\windows\system32\prnmngr.vbs -a -p %PrnName3SW% -m %PrnTypePCL% -r IP_"%PortIP_3_Stock%"

  rem pcl 6 stock s/w
  cscript c:\windows\system32\prnport.vbs -a -r IP_%PortIP_6_Stock% -h %PortIP_6_Stock% -o RAW -n 9100
  cscript c:\windows\system32\prndrvr.vbs -a -m %PrnTypePCL% -v 3 -e "Windows NT x86" -i %InfPath32%
  cscript c:\windows\system32\prnmngr.vbs -a -p %PrnName6SW% -m %PrnTypePCL% -r IP_"%PortIP_6_Stock%"

  rem postscript 3 farbe
  cscript c:\windows\system32\prnport.vbs -a -r IP_%PortIP_3_Stock% -h %PortIP_3_Stock% -o RAW -n 9100
  cscript c:\windows\system32\prndrvr.vbs -a -m %PrnType% -v 3 -e "Windows NT x86" -i %InfPath32ps%
  cscript c:\windows\system32\prnmngr.vbs -a -p %PrnName3Farbe% -m %PrnType% -r IP_"%PortIP_3_Stock%"

  rem postscript 6 farbe
  cscript c:\windows\system32\prnport.vbs -a -r IP_%PortIP_6_Stock% -h %PortIP_6_Stock% -o RAW -n 9100
  cscript c:\windows\system32\prndrvr.vbs -a -m %PrnType% -v 3 -e "Windows NT x86" -i %InfPath32ps%
  cscript c:\windows\system32\prnmngr.vbs -a -p %PrnName6Farbe% -m %PrnType% -r IP_"%PortIP_6_Stock%"
  ) ELSE (
    Echo "This is 64 Bit WinXP"
  rem pcl 3 stock s/w
  cscript c:\windows\system32\prnport.vbs -a -r IP_%PortIP_3_Stock% -h %PortIP_3_Stock% -o RAW -n 9100
  cscript c:\windows\system32\prndrvr.vbs -a -m %PrnTypePCL% -v 3 -e "Windows x64" -i %InfPath64%
  cscript c:\windows\system32\prnmngr.vbs -a -p %PrnName3SW% -m %PrnTypePCL% -r IP_"%PortIP_3_Stock%"

  rem pcl 6 stock s/w
  cscript c:\windows\system32\prnport.vbs -a -r IP_%PortIP_6_Stock% -h %PortIP_6_Stock% -o RAW -n 9100
  cscript c:\windows\system32\prndrvr.vbs -a -m %PrnTypePCL% -v 3 -e "Windows x64" -i %InfPath64%
  cscript c:\windows\system32\prnmngr.vbs -a -p %PrnName6SW% -m %PrnTypePCL% -r IP_"%PortIP_6_Stock%"

  rem postscript 3 farbe
  cscript c:\windows\system32\prnport.vbs -a -r IP_%PortIP_3_Stock% -h %PortIP_3_Stock% -o RAW -n 9100
  cscript c:\windows\system32\prndrvr.vbs -a -m %PrnType% -v 3 -e "Windows x64" -i %InfPath64ps%
  cscript c:\windows\system32\prnmngr.vbs -a -p %PrnName3Farbe% -m %PrnType% -r IP_"%PortIP_3_Stock%"

  rem postscript 6 farbe
  cscript c:\windows\system32\prnport.vbs -a -r IP_%PortIP_6_Stock% -h %PortIP_6_Stock% -o RAW -n 9100
  cscript c:\windows\system32\prndrvr.vbs -a -m %PrnType% -v 3 -e "Windows x64" -i %InfPath64ps%
  cscript c:\windows\system32\prnmngr.vbs -a -p %PrnName6Farbe% -m %PrnType% -r IP_"%PortIP_6_Stock%"
  )
goto exit

:exit
pause</pre>

self extracting 7z archive with linux for windows on command line | 7z sfx in linux für windows

In Anleitungen habe ich nur 2 Befehle gefunden die aber für die Windowswelt gedachte sind (copy /b 7zS.sfx + config.txt + test.7z test.exe):

  • Wenn man mit einer config die Datei erstellen möchte um eventuell nach dem entpacken automatisch ein Setup zu starten, muss man erst das 7z Archiv haben.

    In einer Linux Distribution wird anschließend das ganze mit cat zu einer exe gemacht, wobei 7zS.sfx das Win32 Modul für das Entpacken ist:

    cat /usr/lib/p7zip/7zS.sfx config.txt test.7z > test.exe

    Wenn man ein ganzes Verzeichnis (test) gezippt hat und eine Setup.exe ausführen lassen will nach dem Extrahieren muss man die config.txt wie folgt schreiben:

    ;!@Install@!UTF-8!
    Title="test"
    RunProgram="test\setup.exe"
    ;!@InstallEnd@!

  • Der andere Befehl ist nur mit einer selbstextrahierenden Datei ohne config Datei:

    7z a -sfx7zS.sfx test.exe test/