2016年6月6日 星期一

Create Indexes with Included Columns

https://msdn.microsoft.com/en-nz/library/ms190806.aspx?f=255&MSPPError=-2147217396 @Echo off chcp 1251>NUL Set ScriptVersion=v0.4 SET log_file="%~dp0%~n0.log" call:WRITE_LOG ----- call:WRITE_LOG %ScriptVersion% ver >> %log_file% call:WRITE_LOG ----- REM Check if have admin rights Net SESSION >NUL 2>&1 IF %ERRORLEVEL% NEQ 0 ( call:WRITE_LOG ERROR! Admin required! Pause && Exit ) If Exist "%windir%\SysWow64" ( Set WinSysDir=%windir%\SysWow64 ) Else ( Set WinSysDir=%windir%\System32 ) REM Close Internet Explorer call:KILL_PROCESS iexplore.exe REM Close Skype call:KILL_PROCESS Skype.exe call:KILL_PROCESS SkypeBrowserHost.exe REM Enable Windows Script Host call:REG_DELETE "HKLM\Software\Microsoft\Windows Script Host\Settings" Enabled call:REG_DELETE "HKU\Software\Microsoft\Windows Script Host\Settings" Enabled REM Disable "Enforcing the Use of Signed Scripts" call:REG_DELETE "HKLM\Software\Microsoft\Windows Script Host\Settings" TrustPolicy call:REG_DELETE "HKU\Software\Microsoft\Windows Script Host\Settings" TrustPolicy REM Register DLLs call:EXEC_CMD regsvr32 "%WinSysDir%\jscript.dll" call:EXEC_CMD regsvr32 "%WinSysDir%\vbscript.dll" call:EXEC_CMD wscript /regserver If Exist "%WinSysDir%\jscript9.dll" ( call:EXEC_CMD regsvr32 "%WinSysDir%\jscript9.dll" ) REM Show log file "%WinSysDir%\notepad.exe" %log_file% Exit REM --------------------------------------------- :WRITE_LOG Echo %* >> %log_file% Exit /B :EXEC_CMD call:WRITE_LOG %* Set cmd=%WinSysDir%\%* %cmd% >> %log_file% 2>&1 Echo. >> %log_file% Exit /B :KILL_PROCESS SET process=%* "%WinSysDir%\TaskList.exe" /FI "IMAGENAME eq %process%" 2>NUL | "%WinSysDir%\Find.exe" /I /N "%process%">NUL if %ERRORLEVEL% EQU 0 ( call:EXEC_CMD TaskKill.exe /F /IM %process% /T ) Exit /B :REG_DELETE SET path=%1 SET key=%2 call:EXEC_CMD reg delete %path% /v %key% /f Exit /B :FILE_VERSION FOR /F "tokens=2 delims==" %%I IN ( 'wmic datafile where "name=%*" get version /format:list' ) DO SET "FileVersion=%%I" call:WRITE_LOG Internet Explorer: %FileVersion% >> %log_file% Exit /B