working on it ...


Explore Public Snippets

Sort by

Found 339 snippets

    public by TheFreeman193 modified Feb 21, 2018  468  0  5  0

    Elevate batch script

    Checks for elevation with fsutil, if not found will elevate the current script and terminate the original instance.
    fsutil dirty query %SYSTEMDRIVE% >nul
    if ERRORLEVEL 1 (start /min "" powershell -Command "Start-Process -FilePath '%~f0' -Verb runas" & exit /b)

    public by DinhoPutz modified Oct 5, 2017  313  1  5  1

    Compactar Arquivos para Backup com Winrar

    REM Compactar arquivos para fazer backup. 
    REM Obs, é recomendável que os caminhos dos arquivos não contenham espaço. 
    REM Sobre a linha de comando 
    REM "RAR.exe a": o comando "a" adiciona arquivos no arquivo compacto que esta sendo criado.
    REM "-m5": nível de compressão, que vai de 0 à 5, sendo 5 o nível máximo de compressão.
    REM "-r": Para adicionar pastas e subpastas. 
    REM "-ag": É a marca de tempo, recomendável se for criar backups diário. 
    REM ">>": Gera o arquivo de log e a medida que o backup for sendo executado vai adicionandos novas linhas ao mesmo.
    C:\progra~2\WinRAR\Rar.exe a -m5 -r -ag_yyyy-MM-dd E:\Arquivo1.rar D:\Pasta1\ >> Saida.txt
    C:\progra~2\WinRAR\Rar.exe a -m5 -r -ag_yyyy-MM-dd E:\Arquivo2.rar D:\Pasta2\ >> Saida.txt
    C:\progra~2\WinRAR\Rar.exe a -m5 -r -ag_yyyy-MM-dd E:\Arquivo3.rar C:\Pasta3\ >> Saida.txt						

    public by RexPhillips modified Jul 24, 2017  259  2  4  0


    Powershell snippet to rename files in a directory in a batch mode.
    dir | rename-item -NewName {$ -replace "DEV","PROD"}

    public by maholtz modified Aug 17, 2016  1537  1  4  0

    Windows Batch - for loop

    REM use %%x in Batch file, %x on console
    REM for /l %%x in (START, STEP, END) do (
    for /l %%x in (101, 1, 199) do (
      REM %%x - a longer variable is not allowed?
    	echo Number %%x

    public by cghersi modified Apr 13, 2016  2559  0  5  0

    Transform a JKS keystore in a PEM certificate

    This set of commands transform the certificate from a JKS to a PEM format. It requires JDK keytool and openssl.
    keytool -keystore client.ts -exportcert -alias mobile | openssl x509 -inform der -text
    #psw of keystore: changeit
    keytool -importkeystore -srckeystore client.ts -destkeystore client.p12 -srcstoretype jks -deststoretype pkcs12
    #psw of destination keystore: changeit
    openssl pkcs12 -in client.p12 -out client.pem
    #import psw: changeit

    public by cghersi modified Apr 1, 2016  2559  0  4  0

    Start Eclipse with a non-default JVM

    Eclipse starts with a JMV that is usually the one in the PATH. E.g. the version retrieved thru java --version
    C:\eclipse\eclipse.exe -vm "C:\Program Files\Java\jdk1.6.0_45\bin\javaw.exe"           

    public by cghersi modified Mar 29, 2016  2774  2  7  1

    Enable HTTPS on Tomcat

    How to make the apps running on Tomcat able to publish over https
    // 1. Export certificate request with keytool
    // 1.1 Generate the keytool command with the form at this URL:
    // 1.2 The result will be a pair of file mydomain.jks and mydomain.csr
    // 2. Ask the certificate to the cert authority
    // 2.1 The result will be a pair of file mydomain.pem and mydomain.p7b
    // 3. Import mydomain.pem into mydomain.jks (assuming your alias is "server")
    keytool -import -v -trustcacerts -alias server -file mydomain.pem -keystore iot_bissell_com.jks -storepass <secret_psw>
    // 4. Edit conf/server.xml in the deployment of Tomcat, add this line 
    // (under the element <Service name="Catalina">):
    <Connector SSLEnabled="true" 
     clientAuth="false" keyAlias="server" 
     keystorePass="<secret_psw>" maxThreads="150" port="8080" 
     protocol="HTTP/1.1" scheme="https" secure="true" sslProtocol="TLS"/>            

    public by maholtz modified Oct 20, 2015  2697  1  6  0

    while loop batch

    # In einer Zeile, zählt hoch und wartet dazwischen 10 Sekunden
    # Kann als Basis genommen werden um auf die Schnelle Befehle
    # mit Pause in der Shell zu wiederholen
    a=0; while [ "$a" -lt 100 ]; do echo -n "$a"; sleep 10;  a=`expr $a + 1`; done;

    public by cghersi modified Sep 4, 2015  1955  1  6  2

    Sign a DLL with a strong name

    In some cases a DLL with strong name is required. If you need a third party library but this is not signed, the only way to avoid this problem is to deassembly and reassembly the DLL. Note: this can cause problems in licensing, so be sure that you are not infringing any license agreement!
    rem from a Developer Command Prompt, 
    rem go in the bin folder of your project, where is the dependent library (not signed).
    rem Assume your project depends on Foo, third party library not signed.
    rem 1) Optional, if Foo depends on Foo2, sign all the other dependencies like Foo2:
    ildasm /all / Foo2.dll
    ilasm /dll /key=Key.snk 
    rem 2) disassembly
    ildasm /all / Foo.dll
    rem 3) Optional, if Foo depends on Foo2, add the new public token to
    rem 3.1) Retrieve the public token (e.g. the result of this step will be publictoken=(6B 75 A8 06 B8 60 95 CD )
    sn -Tp Foo2.dll
    rem 3.2) Edit file, changing
    rem .assembly extern /*23000005*/ Foo2
    rem {
    rem  .ver 2:1:12:0
    rem }
    rem  to
    rem .assembly extern /*23000005*/ Foo2
    rem {
    rem  .publickeytoken = (6B 75 A8 06 B8 60 95 CD )                     
    rem  .ver 2:1:12:0
    rem }
    rem 4) riassembly
    ilasm /dll /key=Key.snk 

    public by maholtz modified Jul 27, 2015  2192  0  6  0

    Auf Existenz einer Datei in einem Verzeichnis prüfen

    Ganz einfache Funktion für Windows Batch Dateien zur Überprüfung von Verzeichnissen auf die Existenz von bestimmten Dateien in bestimmten Größen.
    REM Aufruf:
    CALL :checkForFile "\\server\pfad\" "Datei*.xml" 1000 2000 "Gesucht wird Datei*.xml"
    set verzeichnis=%1
    set zieldateien=%2
    set minDateigroesse=%3
    set maxDateigroesse=%4
    set BETREFF=%5
    REM echo Check for %zieldateien% in %verzeichnis% von heute
    echo ! ------------------------------------------
    echo ! %BETREFF%
    set DATEI=""
    for /R %verzeichnis% %%f in (%zieldateien%) do (
    	set DATEI=%%f
    	REM echo %%f mit %%~zf
    	if %%~zf LSS %minDateigroesse% (
    		echo FEHLER: Datei %%f ist mit %%~zf Bytes zu klein!
    		SET /a FEHLER=%FEHLER%+1
    		exit /B -1
    	if %%~zf GTR %maxDateigroesse% (
    		echo FEHLER: Datei %%f ist mit %%~zf Bytes zu gross!
    		SET /a FEHLER=%FEHLER%+1
    		exit /B -2
    if %DATEI%=="" (
    	echo FEHLER: Datei fehlt!
    	echo %zieldateien% in %verzeichnis%
    	exit /B -3
    echo ! OK: %DATEI%
    exit /B 0    
    • Public Snippets
    • Channels Snippets