Skip to content
Snippets Groups Projects
Select Git revision
  • e6af2d07377ed72d87e73ae5d44f2bb1f0d2f002
  • main default protected
2 results

Fix long login times.bat

Blame
  • Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    Fix long login times.bat 1.40 KiB
    @echo off
    REM Ensure Admin rights
    setlocal DisableDelayedExpansion
    set "batchPath=%~0"
    for %%k in (%0) do set batchName=%%~nk
    set "vbsGetPrivileges=%temp%\OEgetPriv_%batchName%.vbs"
    setlocal EnableDelayedExpansion
    net file 1>nul 2>nul
    if '%errorlevel%' == '0' (goto gotPrivileges) else (goto getPrivileges)
    
    :getPrivileges
    if '%1'=='ELEV' (echo ELEV & shift /1 & goto gotPrivileges)
    REM If you have non-ASCII chars in your path you'll need to set the codepage appropriate to your locale:
    REM chcp 1252
    REM (ANSI-Latin1 - Western European, e.g. German)
    cls
    echo Set UAC = CreateObject^("Shell.Application"^) > "%vbsGetPrivileges%"
    echo args = "ELEV " >> "%vbsGetPrivileges%"
    echo For Each strArg in WScript.Arguments >> "%vbsGetPrivileges%"
    echo args = args ^& strArg ^& " " >> "%vbsGetPrivileges%"
    echo Next >> "%vbsGetPrivileges%"
    echo UAC.ShellExecute "!batchPath!", args, "", "runas", 1 >> "%vbsGetPrivileges%"
    "%SystemRoot%\System32\WScript.exe" "%vbsGetPrivileges%" %*
    exit
    
    :gotPrivileges
    if '%1'=='ELEV' (del "%vbsGetPrivileges%" 1>nul 2>nul & shift /1)
    
    
    REM Functional part
    pushd "C:\Users" && (
    for /f "tokens=*" %%a in ('dir /A:D /b') do (
     if not "%%a" == "Public" if not "%%a" == "All Users" if not "%%a" == "Default User" (
     pushd "C:\Users\%%a\AppData\Local\Microsoft\Windows" && (
      rd /s /q WebCache
      del /q /f WebCacheLock.dat
    )
     popd
    )
    )
    popd
    )
    echo Done.
    pause
    exit