Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
:: Name: Startup.Cmd.cmd
:: Purpose: Initializes a Windows command prompt shell
:: Author: stevejansen_github@mac.com
:: Revision: April 2012
@ECHO OFF
SETLOCAL ENABLEEXTENSIONS
:: self-install this script, but, don't force an overwrite if an auto run script is already configured
IF /I "%~1"=="/install" (
ECHO %~n0: installing %~nx0 as the cmd.exe auto-run script
REG ADD "HKCU\Software\Microsoft\Command Processor" /v "AutoRun" /t REG_EXPAND_SZ /d "^"%~f0^""
)
::CHECK if arguments were passed to cmd.exe, if so exit this script
FOR /F "tokens=2" %%I IN ("%CMDCMDLINE%") DO (
IF NOT "%%I"=="" (
ECHO.[%DATE% %TIME%] - AutoRun Disabled - %CMDCMDLINE% >> "%USERPROFILE%\Documents\Scripts\%~n0.history.txt"
GOTO :EOF
) ELSE (
ECHO.[%DATE% %TIME%] - AutoRun Enabled - %CMDCMDLINE% >> "%USERPROFILE%\Documents\Scripts\%~n0.history.txt"
)
)
:: update the path as needed
PATH %PATH%;%ProgramFiles%\SysInternals;
:: Load the DOSKEY macros from ".txt" file in the same folder and same filename as this script
START "" /B DOSKEY /MACROFILE="%~dpn0.txt"
:: change the working directory
IF EXIST P:\ PUSHD P:\
@ECHO ON
@EXIT /B 0
sql=SQLCMD.exe -S lpc:(local)\SQLEXPRESS -E $*
sql.start=SC START MSSQL$SQLEXPRESS
sql.stop=SC STOP MSSQL$SQLEXPRESS
sql.restart=SC STOP MSSQL$SQLEXPRESS ^&^& SC START MSSQL$SQLEXPRESS
git="C:\Program Files\Git\bin\sh.exe" --login -i $*
vs=IF NOT DEFINED DevEnvDir ("%ProgramFiles%\Microsoft Visual Studio 10.0\VC\vcvarsall.bat" %PROCESSOR_ARCHITECTURE%)
control="%SystemRoot%\system32\control.exe" /Name "Microsoft.$1"
appcmd="%ProgramFiles%\IIS Express\appcmd.exe" $*
wix=PATH | FINDSTR/L /C:"Windows Installer XML v3.5\bin" 1>nul 2>nul || PATH %PATH%;%ProgramFiles%\Windows Installer XML v3.5\bin;
ssdt=PATH | FINDSTR/L /C:"Microsoft SQL Server\110\DAC\bin" 1>nul 2>nul || PATH %PATH%;%ProgramFiles%\Microsoft SQL Server\110\DAC\bin
webdeploy=PATH | FINDSTR/L /C:"Microsoft Web Deploy V3" 1>nul 2>nul || PATH %PATH%;%ProgramFiles%\IIS\Microsoft Web Deploy V3
iis=START "" /B taskkill.exe /im:iisexpress.exe 2>NUL && PING localhost /n 2 >nul && START "" "%ProgramFiles%\IIS Express\iisexpress.exe.lnk" /systray:false /trace:warning /siteid:$*
where=@FOR %I in ($1) DO @(IF NOT "%~f$PATH:I"=="" @ECHO.%~f$PATH:I)&&@FOR %I IN (%PATHEXT%) DO @(FOR %J IN ($1%I) DO @(IF NOT "%~f$PATH:J"=="" @ECHO.%~f$PATH:J))
passwd=notepad "%USERPROFILE%\Documents\notes.txt:notes"
localdb="%PROGRAMFILES%\Microsoft SQL Server\110\Tools\Binn\sqllocaldb.exe" start v11.0&&"%PROGRAMFILES%\Microsoft SQL Server\110\Tools\Binn\SQLCMD.EXE" -S (localdb)\v11.0 $*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.