Skip to main content

Posts

Showing posts with the label Task Scheduler

Check Windows Task Scheduler Status and Last Run Time

Task Scheduler is an awesome tool that every Sys Admin should be familiar with it. Task Scheduler in a way can help automate task, if the task is repetitive or a task that has to be done at a certain date and time, or a task has to be done once a week, once a month or even once a year. Task Scheduler is the best tool for this scenario. In this busy world of digital technology, who can keep remembering that a task must be done on a specific date and time. Yes, it might works once but as time goes on and task or jobs of a Sys Admin keep filing up chances are the task might be forgotten and the person-in-charge might just remember the things that needs to be done if there is an issue that happens already. So, Task Scheduler is a tool in which you test once, set if tested okay and forget about it. Test to make sure that the task to be set, works properly and just forgot about it; it will do the task repetitively albeit depends on the settings that was set. Of course, Task Scheduler...

PowerShell launch an application and close it automatically

Code below will run an application and PowerShell will also close it after a few seconds. $process_id = Invoke-CimMethod Win32_Process -MethodName "Create" -Arguments @{ CommandLine = 'cmd /c "C:\dev\remind.bat"' } | Select-Object processid | ft -HideTableHeaders | Out-String   Start-Sleep -Seconds 2.5   stop-process $process_id   Sample contents of remind.bat: @echo off echo "Shutdown the server. Do it now." Notepad ================== Notepad is on the batch file so the command window will stay on the top of any running applications. Sample output of the above code:   Code below will run calculator and close after a few seconds specified on the code: Invoke-CimMethod Win32_Process -MethodName "Create" -Arguments @{ CommandLine = 'calc.exe' } | Select-Object processid | ft -HideTableHeaders | Out-String   Start-Sleep -Seconds 2.5   $get_process_id = Get-Process ...

PowerShell get startup items or files

Checking startup items or files, when Windows is starting or upon user successful login is quite important. Some files need to run on startup so it can be used while the user or computer is being in used. Or the startup files is set, so when the computer starts the file or items will also start. In this way, you don’t have to remember what things to open when the program or items will run during startup. Of course, it’s not only the important files will be set during startup. Some viruses or malware sometimes use this method to load the software, so that they will also be in the system as long as the user is logged in. So, how to check in PowerShell to get all those startup items or files? Here’s the code: Get-CimInstance Win32_StartupCommand | select Description , Command , Location , User , Caption Sample output: Description : OneDrive Command      : "C:\Users\duser_name\AppData\Local\Microsoft\OneDrive\OneDrive.exe" /backg...

Robocopy backup using Task Scheduler

Backup is a simple word that has a very good significant value in today’s digital world. Unattended backup or automated backup is a good strategy, so the user or the whoever is managing the backup won't need to manually trigger the backup. No data backup is a head-on strategy, that leads to catastrophe. Backup is very, very important in today’s digital world. You will never know when a data disaster will strike. The whole laptop will be lost, the hard drive will fail without any sign, a virus might corrupt the whole system or just simple mistake to overwrite or delete a data. All this scenario requires a backup rescue to recover the data. Robocopy is a built-in command in Windows that does a pretty awesome job to backup or copy files. Using Windows task scheduler, robocopy and Vbscript will create an important task to backup data. How the three tools will be used, to backup data? Robocopy – to backup or copy the files Vbscript – to hide the roboco...

Access denied renaming shared folder

If you are working in a shared active directory environment and has a shared folder that needs to be renamed once in a while. But every time you want to rename there is always a user who is using the folder and therefore, renaming the folder is denied. How to rename the folder when the shared folder is always in use? Automation will come for the rescue in such a scenario. How to automate renaming the folder? Task scheduler and a simple batch file can do the task and a life saver. Here's how to do it: Of course, disconnect all the open files. Users should shutdown their computers when they went out of the office, If they don't shutdown, force their disconnection by using the command below: openfiles /disconnect /o read/write openfiles /disconnect /o no access Then, rename the folder with the ren or rename command of course. Syntax is the good old fashioned source folder or path and the new folder name. If the batch file will ...

Ping range of IP Address via command line

How to ping range of IP Address via command line? Ping a range of IP Address via command line, quite useful in a server core environment or set to task scheduler and run at specific time and day. Batch files still does it wonder. Below is a command line that can be save as a batch file and set via task scheduler to automatically run at a specified time or day. Batch file script to ping a range of IP and save to notepad the result. ====================================== FOR /L %I IN (100,1,220) DO   echo %date%   %time% 2 >> d:\pingx.txt   & ping 192.168.1.%I -n 2 >> d:\pingx.txt ====================================== The command will ping   iP range 192.168.1.100 to 192.168.1.220 and send 2 echo request. Results of the ping is save on drive d at a file named pingx.txt. Copy the command to notepad and save it as a batch file with extension of “.bat” or “.cmd”. Sample output: Wed 11/11/2015   17:31:15.0...