Created
February 25, 2019 22:47
-
-
Save niikoo/30debb315de8515c3afe9f53bc44a73b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@ECHO OFF | |
TITLE MOVE AND RELINK V2.2 BY NIIKOO | |
ECHO. | |
ECHO ============================== | |
ECHO Move and relink v2.2 by niikoo | |
ECHO ============================== | |
SET src="%~2" | |
ECHO SOURCE: %src% | |
SET dst="%~1%src:~3,-1%" | |
ECHO DESTINATION: %dst% | |
ECHO. | |
:ALLOW_IT | |
SET this_path=%~0 | |
SET this_path=%this_path:~0,-20% | |
SET batch_script=%this_path%\do.bat | |
SET allow=n | |
SET /P allow=Is this correct and is all programs using this directory closed? (y/n) : | |
IF %allow% == n EXIT | |
IF %allow% == y GOTO continue1 | |
ECHO. | |
ECHO Only y or n allowed | |
ECHO. | |
GOTO ALLOW_IT | |
:continue1 | |
CLS | |
DEL %batch_script% | |
ECHO @ECHO OFF > %batch_script% | |
ECHO TITLE Moving and relinking... >> %batch_script% | |
ECHO MKDIR %dst% >> %batch_script% | |
ECHO C:\windows\system32\CMD.exe /C XCOPY %src% %dst% /A /E /C /H /R /K /-Y /O /X >> %batch_script% | |
ECHO IF NOT EXIST %dst% EXIT >> %batch_script% | |
ECHO C:\windows\system32\CMD.exe /C DEL /F /S /Q %src% >> %batch_script% | |
ECHO C:\windows\system32\CMD.exe /C RMDIR /S /Q %src% >> %batch_script% | |
ECHO C:\windows\system32\CMD.exe /C MKLINK /D %src% %dst% >> %batch_script% | |
ECHO ECHO. >> %batch_script% | |
ECHO ECHO. >> %batch_script% | |
ECHO ECHO. >> %batch_script% | |
ECHO ECHO Move and Relink complete! Press any key to exit >> %batch_script% | |
ECHO ECHO If there's a problem with the symlink creation, then maybe a program is using some of the files. >> %batch_script% | |
ECHO PAUSE >> %batch_script% | |
CLS | |
ECHO. | |
ECHO ============================= | |
ECHO Running Admin shell | |
ECHO ============================= | |
:checkPrivileges | |
NET FILE 1>NUL 2>NUL | |
if '%errorlevel%' == '0' ( goto gotPrivileges ) else ( goto getPrivileges ) | |
:getPrivileges | |
if '%1'=='ELEV' (shift & goto gotPrivileges) | |
ECHO. | |
ECHO ************************************** | |
ECHO Invoking UAC for Privilege Escalation | |
ECHO ************************************** | |
setlocal DisableDelayedExpansion | |
set "batchPath=%batch_script%" | |
setlocal EnableDelayedExpansion | |
ECHO Set UAC = CreateObject^("Shell.Application"^) > "%temp%\OEgetPrivileges.vbs" | |
ECHO UAC.ShellExecute "!batchPath!", "ELEV", "", "runas", 1 >> "%temp%\OEgetPrivileges.vbs" | |
"%temp%\OEgetPrivileges.vbs" | |
exit /B | |
:gotPrivileges | |
:::::::::::::::::::::::::::: | |
::START | |
:::::::::::::::::::::::::::: | |
setlocal & pushd . | |
%this_path%\psexec.exe -h "C:\Windows\System32\cmd.exe /C \"%batch_script%\"" |
Needs PsExec.exe at the same location as the bat file. Get it from Microsoft sysinternals.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Install script:
N:\\
with the desired folder to move stuff to..reg
and run it.