:: Open folders
start %USERPROFILE%Documents
start %USERPROFILE%DesktopMusicFolder
:: Open files
start chrome.exe
start
""
"%USERPROFILE%DocumentsMy BlogsArticle1.docx"
start
""
"%USERPROFILE%DocumentsContent Ideas.xlsx"
exit
To start the program as an admin you need to do it differently than above. That's because this program requires admin access by displaying the UAC prompt. If you do not approve the prompt, these programs will not start.
Using a shortcut placed in the Windows Startup folder does not work, so what to do? The Task Scheduler program will be the solution to this problem. It has only one option to run the program with administrative rights, so you can start one or more applications (using batch scripts) using Task Scheduler. Here's how:
Step 1: Open Task Scheduler > click " Create Task " in Actions in the right panel.
Step 2 : On the General tab, name the task as " NoUAC1 ", then select the " Run with highest rights " option.
Step 3 : Click on the Trigger tab, in the ' Begin the task ' section, select ' At startup '.
Step 4 : Now switch to the Actions tab, click New .
Step 5 : In the New Action window, in the Action select " Start a program ", in Program / script , click the Browse button, select the executable file you want to schedule and click OK .
Step 6 : Now, go to the Settings tab, select the option ' Allow task to be run on demand ' and then click OK to save.
Now the program (Adobe Reader in this tutorial) will automatically start with admin rights when booting the system.
If you are a technology enthusiast or developer, you often have to download and test many things. After a while, you'll see there are some unnecessary files "available" on your system because they take up space on your computer. There is a very good solution for this instead of having to manually delete that is to create a batch script to delete old download files.
Similarly, you can use batch files to delete all old files of specific extensions or files in a folder or sub-folder. To do this, you'll use the code below to delete the .docx file (change 'docx' to a file that suits you) in a specific folder with a time longer than twenty days (change the value of the option ' / d 'into any day).
@
echo
off
forfiles
/p
"%USERPROFILE%DocumentsMy Blogs"
/s
/m
*.docx
/d
-20
/c
"cmd /c del @path"
echo
Document files older than 20 days deleted
pause
exit
You can change the path (by changing the value of the " / p " option) to the directory containing the files to delete. Below, ' % USERPROFILE% ' means your user directory.
You should delete the recycle bin regularly and although it is an easy task, users often forget it. Fortunately, you can automate this task using Task Scheduler. Here's how to free up free space on your hard drive:
Step 1: Open Task Scheduler.
Step 2 : Open " Task Scheduler Library ", then in the Action menu, click on " New Folder " and name it " My Tasks ".
Step 3: Click on the ' My Tasks ' folder and select ' Create Task ' from the Action menu.
Step 4: In the Create Task window under the General tab, type the task name as " Empty Recycle Bin ".
Step 5 : Click on the Triggers tab, click New and in the ' Begin the task ' section, select ' On a schedule '.
Step 6 : Select Weekly or Monthly options to set the time to delete the file and click OK .
Step 7 : Click on the Actions tab, move to New and in the New Action window, in Settings , type " PowerShell.exe " in the Program / script section .
Step 8 : In the same window, in the " Add arguments (optional) " type -NoProfile -Command " Clear-RecycleBin -Force" and click the OK button.
Now, your trash will be cleaned according to schedule.
For those who are passionate about working all night, this task is very useful, because it shows the message to turn off the computer, forcing them to stop working and on vacation. The code below will display the message (you can edit it in the script) at 11pm and turn off the system after 120 seconds (or 2 minutes). Note, you can change the shutdown time in the code below by changing the % time% value.
@
echo
off
:a
If %
time
%==23:00:00.00 goto :b
goto a:
:b
shutdown
.exe
/s
/f
/t
120
/c
"Time To Say Good Night!"
exit
Note : You will have 120 seconds to save the job instead of the default 30 seconds. Alternatively, you can stop the shutdown process by pressing Win + R and typing shutdown -a , then press Enter .
There are many good programs to back up files, including cloud solutions like Dropbox and Backup and Sync from Google. However, if you want more control and backup of sensitive files to a portable hard drive, you can use a batch automation solution.
Note, this method only backs up specific files and folders, does not create a system restore point or back up the system. Below is the code of the batch file to back up all data inside the user directory and back up the system registry:
@
echo
off
:: Set the folder to backup below
set
sourcedir=C:UsersUSER
:: Set your portable drive's folder below
set
targetdir=D:Backup
if
not exist
"%targetdir%"
mkdir
"%targetdir%"
echo
### Backing up your profile…
robocopy %sourcedir% %targetdir% *
/e
/j
/r
:10
/v
echo
### Backing up the registry…
if
exist
"%targetdir%regbackup.reg"
del
"%targetdir%regbackup.reg"
regedit.exe
/e
"%targetdir%regbackup.reg"
echo
### Backup is all complete…
pause
exit
I wish you all success!
See more: