Batch scripts and snippets #bat #batchscripting
cd /d %~dp0
if /i "%PROCESSOR_IDENTIFIER:~0,3%"=="X86" (
echo system is x86
regsvr32 %windir%\system32\yourDLL.dll -u
#Optional Delete Dll after unregistration
del %windir%\system32\yourDll.dll
) else (
echo system is x64
regsvr32 %windir%\SysWOW64\yourDll.dll -u
#Optional Delete Dll after unregistration
del %windir%\SysWOW64\yourDLL.dll
)
cd /d %~dp0
if /i "%PROCESSOR_IDENTIFIER:~0,3%"=="X86" (
echo system is x86
copy .\*.dll %windir%\system32\
regsvr32 %windir%\system32\yourDll.dll
) else (
echo system is x64
copy .\*.dll %windir%\SysWOW64\
regsvr32 %windir%\SysWOW64\yourDll.dll
)
@ECHO OFF
REM The following directory is for .NET 4.0
echo Directory C:\Windows\Microsoft.NET\Framework\v4.0.30319
set DOTNETFX4=%SystemRoot%\Microsoft.NET\Framework\v4.0.30319
set PATH=%PATH%;%DOTNETFX4%
echo Uninstalling ...
echo ---------------------------------------------------
InstallUtil /u "ServiceLocation\ServiceName.exe"
echo ---------------------------------------------------
echo Done.
@ECHO OFF
REM The following directory is for .NET 4.0
echo Directory C:\Windows\Microsoft.NET\Framework\v4.0.30319
set DOTNETFX4=%SystemRoot%\Microsoft.NET\Framework\v4.0.30319
set PATH=%PATH%;%DOTNETFX4%
echo Installing ...
echo ---------------------------------------------------
InstallUtil /i "ServiceLocation\ServiceName.exe"
echo ---------------------------------------------------
echo Done.
#Edit Environment Variable, Windows
rundll32.exe sysdm.cpl,EditEnvironmentVariables
@ECHO OFF
Powershell.exe -ExecutionPolicy [System.Reflection.Assembly]::LoadFrom("YourDllName.dll").GetName().Version
# Copy Files to a different directory
copy /Y "$(TargetDir)$(ProjectName).dll" "D:\packages\$(ProjectName).dll"
# Batch script to execute all the sql scripts located in a folder
# 1. Create .bat file within the folder of your .sql scripts
# 2. Copy paste the following and update the creds
# 3. Fire up a command prompt and execute the script
for %%G in (*.sql) do sqlcmd /S Your-ServerIP-Or-InstanceName /d Your-DB-Name /U Your-DB-UserName /P Your-DB-Password -i "%%G"
pause