Script for transferring desktop icons from the previous user

  • updated

After applying Hard mode, a new Windows user is created and for convenience you need to move all the desktop content from the previous user to the new user's desktop, for this I wrote a simple one .bat script that will perform this operation to transfer icons and all folders.

@echo off

:: BatchGotAdmin
REM  --> Check for permissions
>nul 2>&1 "%SYSTEMROOT%\SysWOW64\cacls.exe" "%SYSTEMROOT%\SysWOW64\config\system"
) ELSE (
>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"

REM --> If error flag set, we do not have admin.
if '%errorlevel%' NEQ '0' (
    echo Requesting administrative privileges...
    goto UACPrompt
) else ( goto gotAdmin )

    echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
    set params= %*
    echo UAC.ShellExecute "cmd.exe", "/c ""%~s0"" %params:"=""%", "", "runas", 1 >> "%temp%\getadmin.vbs"

    del "%temp%\getadmin.vbs"
    exit /B

    pushd "%CD%"
    CD /D "%~dp0"

robocopy C:\Users\<PREVIOUS_USER>\Desktop %HOMEPATH%\Desktop /E

start "" "%HOMEPATH%\Desktop\Vektor T13 - All Ok!.exe"


Most of the script takes getting administrator rights, this part is highlighted accordingly.

Copy all the content to a text editor and save it as .bat script. Then put this script on the master (parent) system, for example, on a local disk in root directory, since placing on the desktop, after completing Hard mode, new user will be created, as mentioned earlier and have to go to the desktop folder and from there run the script – it's uncomfortable, so I put in the root of drive C execute the script from there.

Also, note that before closing the script execution console, the Vektor T13 - All Ok! utility is run. This line can be removed at will, but I leave it for my own convenience, because after Hard mode, I immediately perform Soft mode, and I recommend that you do so.