working on it ...

Filters

Explore Public Snippets

Sort by

Found 2,166 snippets matching: cmd

    public by skaggej  219420  2  6  0

    SharePoint 2010 - List All SharePoint PowerShell Cmdlets

    This is a quick and easy way to view and save all of the PowerShell cmdlets that are available for SharePoint. It's quite useful to have this list of commands handy. Once you know which command you want to run, then it's time to learn how to use it with Get-Help.
    Get-Command -Module Microsoft.SharePoint.PowerShell | Select Name >> C:\AllSharePointPowerShellCmdlets.txt
    

    public by aknorr  171913  0  3  0

    convert VHD file to RAW Image

    convert VHD file to RAW Image: vhd2raw.cmd
    qemu-img convert -O raw source.vhd output.raw
    
    

    public by lbottaro  2676  8  6  2

    How to detect your computer's RAM configuration via cmd prompt

    Using this simple WMI (Windows Management Instrumentation) command you can see how your RAM is configured on your pc. The output shows how many banks are used and their capacity. Output: Microsoft Windows [Version 6.3.9600] (c) 2013 Microsoft Corporation. All rights reserved. C:\wmic MEMORYCHIP get banklabel, devicelocator, caption, capaci
    C:\>wmic MEMORYCHIP get banklabel, devicelocator, caption, capacity

    public by lbottaro  3530  1  5  0

    Python execute shell cmd

    This python script runs a shell in linux and executes the cmd or script in a new thread. Python polls the thread till it has some output and save it to file, as well as standard error redirection to file. Then close both file descriptors.
    logFile = open(outputDir + '/build_log.txt',"w")
    errFile = open(outputDir + '/build_err.txt',"w")
    
    compileProcess = Popen(<CMD_or_SCRIPT>, shell=True, executable='/bin/tcsh', stdout=PIPE, stderr=errFile)
    
    while (True):
    	output = compileProcess.stdout.readline()
            if output == "":
            	break
            logFile.write(output)
    
    logFile.close()
    errFile.close()

    public by lbottaro  2251  0  5  0

    Linux SSH remote shell cmd

    This command allows to execute a cmd or script in a xterm shell remotely on another machine via ssh. Xterm will popup showing the cmd execution
    ssh -Y <HOSTNAME> xterm -bg DarkBlue -fg white -geometry 128x24 -sl 200000 -hold -T <TERM_TITLE> -exec '<CMD_or_SCRIPT>'

    public by JKCPR  2376  0  6  1

    Adding directory to path in DOS cmd

    To add install directory to your path, you can type the following command into the command prompt on a DOS box:
    set path=%path%;C:\python34
    
    // Typing an end-of-file character (Control-D on Unix, Control-Z on Windows)
    // at the primary prompt causes the interpreter to exit with a zero exit status.
    
    // If that doesn’t work, you can exit the interpreter by typing the following
    // command: quit().
    
    // If you dont understand what this command is capable of?
    // You should have a quick read up on it :
    // http://en.wikipedia.org/wiki/List_of_DOS_commands
    

    public by juntalis  1628  9  5  0

    Common-use functions for batch

    A collection of utility functions for use in Windows batch scripts. Functions near the bottom may or may not cleanly work in all situations. Still need to work the kinks out of them.
    @echo off
    
    :dirname
    rem Given a filepath, resolve the absolute filepath of its parents folder.
    rem \param [out] %1 - The variable name to output the results to.
    rem \param [in]  %2 - The filepath that we'll be operating on.
    call set "%~1=%%~dp2"
    call set "%~1=%%%~1:~0,-1%%"
    goto :EOF
    
    :filename
    rem Given a filepath, extract the filename. (name and file extension)
    rem \param [out] %1 - The variable name to output the results to.
    rem \param [in]  %2 - The filepath that we'll be operating on.
    call set "%~1=%~nx2"
    goto :EOF
    
    :basename
    rem Given a filepath, extract the basename. (name without file extension)
    rem \param [out] %1 - The variable name to output the results to.
    rem \param [in]  %2 - The filepath that we'll be operating on.
    call set "%~1=%~n2"
    goto :EOF
    
    :abspath
    rem Resolve the absolute filepath to a file or folder.
    rem \param [out] %1 - The variable name to output the results to.
    rem \param [in]  %2 - The filepath that we'll be operating on.
    call set "%~1=%~f2"
    goto :EOF
    
    :which
    rem Get the path of the program in arg 2 and set the variable who's
    rem name was specified in the first argument.
    rem \param [out] %1 - The variable name to output the executable path to.
    rem \param [in]  %2 - The executable name to search for.
    call set "%~1=%~f$PATH:2"
    goto :EOF
    
    :trimslashes
    rem Trims all trailing '/' and '\')from a variable.
    rem \param [inout] %1 - The name of the variable we'll be operating on.
    call set "__C=%%%~1:~-1%%"
    if not "%__C%x"=="\x" if not "%__C%x"=="/x" (set "__C=" & goto :EOF)
    call set "%~1=%%%~1:~0,-1%%"
    goto trimslashes
    
    :strlen
    rem Determine the length of the string specified in the second argument.
    rem \param [out] %1 - The variable name to output the results to.
    rem \param [in]  %2 - The subject text that we will be measuring.
    setlocal
    set _STRLEN_BUFFER_=%~2
    set /A _STRLEN_LENGTH_=0
    :strlen_loop
    if "%_STRLEN_BUFFER_%x"=="x" goto strlen_continue
    set _STRLEN_CHAR_=%_STRLEN_BUFFER_:~0,1%
    set /A _STRLEN_LENGTH_ += 1
    set _STRLEN_BUFFER_=%_STRLEN_BUFFER_:~1%
    goto strlen_loop
    :strlen_continue
    endlocal & call set %~1=%_STRLEN_LENGTH_%
    goto :EOF
    
    :rreplace
    rem Replaces recursively.
    rem \param [out] %1 - The variable name to output the results to.
    rem \param [in]  %2 - The subject text to search and replace through.
    rem \param [in]  %3 - The substring to search for in %2.
    rem \param [in]  %4 - The replacement text to substitute when %3 is found.
    call set "%~1=%~2"
    verify>nul
    :rreplace_work
    (call echo %%%~1%%|find "%~3")>nul 2>nul
    if errorlevel 1 goto rreplace_done
    verify>nul
    call set "%~1=%%%~1:%~3=%~4%%"
    goto rreplace_work
    :rreplace_done
    verify>nul
    goto :EOF
    
    :tolower
    rem Subroutine to convert a variable VALUE to all lower case.
    rem The argument for this subroutine is the variable NAME.
    for %%C in ("A=a" "B=b" "C=c" "D=d" "E=e" "F=f" "G=g" "H=h" "I=i" "J=j" "K=k" "L=l" "M=m" "N=n" "O=o" "P=p" "Q=q" "R=r" "S=s" "T=t" "U=u" "V=v" "W=w" "X=x" "Y=y" "Z=z") do @call set "%~1=%%%~1:%%~C%%"
    goto :EOF
    
    :isdefined
    rem Checks if a variable has a defined value.
    if "%~1x"=="x" exit /B 1
    if not defined %~1 exit /B 1
    goto :EOF
    
    :splitenv
    rem Given an expandable environment variable such as PATH or PATHEXT,
    rem split the variable into its individual lowercase components such that the
    rem value of:
    rem   .COM;.BAT;.EXE
    rem would expand into:
    rem   ".COM" ".BAT" ".EXE"
    rem The resulting value should be suitable for using with the FOR command.
    call set %~1=%%%~2:;=" "%%
    call set %~1="%%%~1%%"
    call :tolower "%~1"
    goto :EOF
    
    :whichex
    rem Similar to the original which above, but with additional functionality
    rem to use the PATHEXT variable when the executable is specified without a
    rem file extension. (ex: Specifying cmd.exe as cmd)
    rem \param [out] %1 - The variable name to output the executable path to.
    rem \param [in]  %2 - The executable name to search for.
    setlocal
    set _WHICHEX_TARGET_=%~2
    call :which _WHICHEX_RESULT_ "%_WHICHEX_TARGET_%"
    if exist "%_WHICHEX_RESULT_%" goto whichex_success
    if not "%~x2x"=="x" goto whichex_failure
    goto whichex_pathext
    :whichex_testpath
    rem Given a file basename and extension, see if we can find a matching
    rem executable on the system PATH.
    if errorlevel 1 exit /B %ERRORLEVEL%
    call :which _WHICHEX_RESULT_ "%~1%~2"
    if exist "%_WHICHEX_RESULT_%" exit /B 1
    goto :EOF
    :whichex_pathext
    rem No file extension was found on our executable name. First we'll try
    rem a search with no extension, (as it was specified) and if that fails,
    rem we'll try the search again with each file extension in PATHEXT until
    rem we find a match. (or run out of extensions)
    call :splitenv _WHICHEX_PATHEXT_ PATHEXT
    for %%E in (%_WHICHEX_PATHEXT_%) do @call :whichex_testpath "%~nx2" "%%~E"
    rem When an executable is found, the errorcode is set to 1 to indicate success.
    if errorlevel 1 goto whichex_success
    rem If it's still zero at this point, that means we failed to find our executable.
    goto whichex_failure
    :whichex_success
    rem We maanged to resolve the executable path, which is now stored in a
    rem localized variable named _WHICHEX_RESULT_. Copy that value over to
    rem our outgoing parameter and cleanup.
    verify>nul
    call set _WHICHEX_COPYCMD_=set "%~1=%_WHICHEX_RESULT_%"
    endlocal & call %_WHICHEX_COPYCMD_%
    goto :EOF
    :whichex_failure
    rem We failed to find the executable path based on the info given. Clean
    rem up and report the error.
    set _WHICHEX_RESULT_=
    endlocal
    call set %~1=%_WHICHEX_RESULT_%
    exit /B 1
    
    
                            

    public by TheFreeman193  549  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 virgilwashere  2240  3  6  0

    Comment-based Help for function or script

    Comment-based Help for function or script
    <#
     .Notes
     NAME:		$($MyInvocation.MyCommand.Name)
     AUTHOR:	$($env:USERNAME)
     
     CREATED:	dd/MM/yyyy
     LASTEDIT:	$(Get-Date -f 'dd/MM/yyyy')
     
     Version:	1.0 Initial Release
    			1.1 Added Feature X
     
     .Synopsis
     One line blurb that discusses cmdlet
    
     .Description
     Multi-line description of cmdlet
    
     .Parameter ParameterName1
     Description of ParameterName1
    
     .Parameter ParameterName2
     Description of ParameterName2
    
     .Inputs
     Information about the types of input objects accepted
    
     .Outputs
     Information about the objects returned as output from the cmdlet
    
     .Example
     Detailed example.  Ideally there should be an example for each set of Parameters and a pipeline example.
    
     .Example
     Additional example
    
     .LINK
     Related cmdlets or relevant URL
    #>

    public by Alessio Felicioni  9044  1  4  1

    scheduled task command, windows host (warning: not just a CTRL+C & CTRL+V crontab replacement). Scheduled for every Monday at 20:15

    scheduled task command, windows host (warning: not just a CTRL+C & CTRL+V crontab replacement). Scheduled for every Monday at 20:15: windows-scheduled-task.cmd
    schtasks /create /tn "Namespace\Scheduled Task" /tr "php -f C:\xampp\htdocs\index.php" /sc weekly /d MON /st 20:15
    
    
    • Public Snippets
    • Channels Snippets