Search code examples
windowscmdadministrator

run cmd with clink as administrator in windows to save your command history permanently


I downloaded clink because I wanted a windows cmd interface that saved the history of the commands I was introducing. The problem is that clink always run in a non admin user, even if you execute the Batch file Clink v0.4.9 as admin. So I want to know how to make Clink run as it is intentionally executed.

enter image description here


Solution

  • In the Batch file Clink v0.4.9, the last lines are written as

    :launch
    start "Clink" cmd.exe /s /k ""%~dpnx0" inject %clink_profile_arg%"
    exit /b 0
    

    So you just need to change them for these

    :launch
    start "Clink" cmd.exe /s /k pushd ""%V"" ""%~dpnx0" inject %clink_profile_arg%"
    exit /b 0
    

    If you want to check whether you are in admin mode, use

    net session 
    

    as indicated in the following stackoverflow post

    How to detect if CMD is running as Administrator/has elevated privileges?

    Now you have a windows cmd which saves your command history permanently in user and admin modes.

    enter image description here