When i restart my windows laptop. there some pop up coming where some cmd is running and disappeared. How to know what command is running?
Background command is running in windows
If a Command Prompt (cmd.exe) window appears briefly when you restart your Windows laptop and then disappears, it might be due to a scheduled task, startup program, or background process executing commands. Here’s how you can identify what command is running:
1. Check Windows Task Scheduler
Many background scripts or commands run via the Task Scheduler. To check:
- Press
Win + R
, typetaskschd.msc
, and hit Enter. - In the left panel, expand Task Scheduler Library.
- Look for suspicious tasks under Active Tasks.
- Click on a task and check the Actions tab to see the command it executes.
- If you find any unusual tasks, disable or delete them.
2. Use Event Viewer
Windows logs startup events, including scheduled tasks and script executions.
- Press
Win + R
, typeeventvwr.msc
, and hit Enter. - Navigate to Windows Logs > Application or System.
- Look for events around the time you restarted.
- If you find an event related to
cmd.exe
, check the details for the executed command.
3. Check Startup Programs (Task Manager)
- Press
Ctrl + Shift + Esc
to open Task Manager. - Go to the Startup tab.
- Look for unknown or suspicious programs running at startup.
- Disable unnecessary entries by right-clicking and selecting Disable.
4. Enable Command Prompt Logging
If the above methods don’t work, enable command logging to capture the command:
- Open Notepad and paste the following:
@echo off echo %DATE% %TIME% - %CMDLINE% >> C:\command_log.txt
- Save it as
log_cmd.bat
. - Press
Win + R
, typegpedit.msc
, and go to:- Computer Configuration > Windows Settings > Scripts (Startup/Shutdown) > Startup.
- Add the
log_cmd.bat
file. - Restart your PC and check
C:\command_log.txt
for recorded commands.
5. Check Registry for Startup Scripts
- Press
Win + R
, typeregedit
, and hit Enter. - Navigate to:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run
HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Run
- Look for suspicious entries running CMD or scripts.
- Delete unwanted entries carefully.
6. Use Autoruns (Microsoft Tool)
A more advanced way is to use Autoruns by Microsoft:
- Download Autoruns from Microsoft Sysinternals.
- Run it as Administrator.
- Check the Logon and Scheduled Tasks tabs for any unknown CMD-related entries.
- Disable unnecessary items.
7. Check Windows Defender or Antivirus Logs
Sometimes malware or scripts execute commands on startup. Run a full system scan using Windows Defender or any antivirus to detect hidden scripts.
Conclusion
If you see a command window briefly appearing on startup, it is likely a scheduled task, startup script, or malware. Using Task Scheduler, Event Viewer, Registry Editor, or Autoruns, you can identify and stop the unwanted command.