Search This Blog

Saturday, July 1, 2023

CMD: Access files without logging in

If you are locked out of your computer and you still want to access the system you can follow these steps.

Most likely you will be locked out from C: drive where your personal data might be stored due to Bitlocker, but this is how you can browse around and find out.

Shift click on restart, go to troubleshooting and advanced tools. Choose the command prompt.

Now you have an administrative prompt starting in the X: drive, here are a few things you can explore.

  • Run wmic logicaldisk get name to find out what drives there are, you can even access a connected USB drive this way. Take note of the name if you want to use it.

  • You can explore other drives by running cd /d d: for example, where d: is the other drive, in this example the USB that I connected.

  • Use the command dir to list all the directories and files in your current folder. Use cd to get the name of your current location.

  • You can navigate by supplying the full path, or the next directory.
    Example: cd d:\folder\folder2

  • To go back up one level use the command cd .. 

  • In this administrative prompt you are actually running an instance of Windows PE, a light-weight OS, also known as Windows Preinstallation Environment. It has limited functionality.
    You can still use the command prompt to start basic programs such as taskmgr, notepad and regedit.

    You can use notepad to edit and save scripts on your USB. First navigate to the right directory, then pick the program and file as shown below.

    Example: notepad myscript.bat

    From task manager you can trigger "run" as well, but executables such as powershell.exe are not available. Nor can you bring a copy of Powershell with you on the USB.

  • You can run batch files, .bat, from your USB. Just navigate to the directory and write the name of the script.

    This is an example of how you can extract data from the registry and save it to your USB using a batch file. Put this code in a text file and save it as a .bat file.

    Make sure that you replace D:\ with whatever drive your USB is.
@echo off
    setlocal
        cd /d D:\
          echo %cd%

              :PROMPT
                SET /P RUSURE=Are you sure (Y/N)?
                  IF /I "%RUSURE%" EQU "N" GOTO END
                    IF /I "%RUSURE%" EQU "Y" GOTO PAYLOAD

                        :PAYLOAD
                          reg save hklm\sam ./sam.save /y
                            reg save hklm\system ./system.save /y

                                :END
                                  endlocal

                                  • Finally, to clear text use cls and to exit the prompt window use exit, which will return your to the recovery environment. From there you can return to the normal OS.

                                  No comments:

                                  Post a Comment