Scripting Windows Platform

List of useful DOS Commands

This DOS commands list is useful when you need to control remotely a computer.

Enable Firewall

NetSh Advfirewall set allprofiles state on

Disable Firewall

NetSh Advfirewall set allprofiles state off

Create Task

SchTasks /Create /SC DAILY /TN TaskName /RU %host%\username /RP userpassword /TR c:\temp\tasktoexecute.exe /RL HIGHEST /ST 07:30 /f

Delete Task

SchTasks /Delete /TN HITBACKUP_PST /f

Power Plans

Use powercfg.exe to control power plans—also called power schemes—to use the available sleep states, to control the power states of individual devices, and to analyze the system for common energy-efficiency and battery-life problems.

powercfg.exe -x -monitor-timeout-ac 0

powercfg.exe -x -monitor-timeout-dc 0

powercfg.exe -x -disk-timeout-ac 0

powercfg.exe -x -disk-timeout-dc 0

powercfg.exe -x -standby-timeout-ac 0

powercfg.exe -x -standby-timeout-dc 0

powercfg.exe -x -hibernate-timeout-ac 0

powercfg.exe -x -hibernate-timeout-dc 0

Copy file

copy “Filessource” filedestination”

Kill task

Taskkill /IM outlook.exe /F

Add port

netsh firewall add portopening  TCP 80 TCP80 enable subnet

Delete temp file

del /F /Q /S C:\Users\username\AppData\Local\Temp\*.*