Monthly Archive December 2016

ByChris Hall

Automatic or Silent running of the Windows Disk Cleanup tool


Note: Before following the below procedure, if you are running Windows Server 2008/2012 please be sure to install the ‘Desktop Experience’ feature from Server Manager.

1. Run the below from a command prompt or run dialog window. The /sageset command allows you to record required settings for the Disk Cleanup tool to run silently.

%windir%\system32\cleanmgr.exe /sageset:1

Note: The /sageset:1 can actually be any number up to 65535. This is done so you can have multiple saved settings.

2. Once run, the Disk Cleanup tool will show. Tick your required files to be cleaned (or all) and click OK to save.

3. Create a scheduled task in Windows running the below command. This will repeat as scheduled cleaning the same selected files each time it is run. You can create multiple schedules for each setting you have saved by typing the required saved numbers in the /sagerun option (those you have set in step 1).

%windir%\system32\cleanmgr.exe /sagerun:1

ByChris Hall

Batch Script – Wait for ping response and then run a command

@echo off

rem REPLACE PC NAME/IP ADDRESS BELOW WITH REQUIRED.
set pc_name=192.168.1.1

:start
echo Please wait, testing if PC is online.
cls
ping -n 1 %pc_name% > nul
if %errorlevel% == 0 goto run_command
echo.
echo PC is currently offline.
echo.
echo Waiting 120 seconds…
ping -n 120 127.0.0.1 > nul
goto start

:run_command
cls
echo PC is online. Waiting 60 seconds for services to start.
echo.
ping -n 60 127.0.0.1 > nul
echo.
echo Running command…
echo.

REM COMMAND TO RUN GOES HERE.

goto END

:END
pause

ByChris Hall

Deleting Windows 7 Print Drivers – The Specified Printer Driver is Currently in Use

In the past we’ve had to delete some network printers drivers on couple of Windows 7 machines.
As usual went to Print Server > [computer] > Drivers > [driver] > Remove Driver Package
After confirming removal by clicking Delete was presented with an error message:
Failed to remove driver [driver name]. The specified printer driver is currently in use.

Windows XP these kind of issues would be normally resolved by deleting printer and restarting Print Spooler service. Unfortunately in this case it didn’t work.

A quick search online revealed that often recommended solution is to delete printer from every single user profile who was ever logged on this machine. We had over 10 user profiles on this machine so we weren’t very keen to try it.

After some searching we found another, quicker way to achieve the same result. The trick is to delete the driver during the start of the print spooler service.

– Open Devices and Printers and remove device(s) which is using drivers in question.

– Open Print Management and Services management consoles side by side.

– In Print Management right click on the driver you want to remove and click Remove Driver Package

– A confirmation dialog will pop up with a Delete button shown, leave this screen open and do not click Delete at this time.

– Open the Services Dialog.

– In Services right click on Print Spooler and click Stop

– In Services right click on Print Spooler and click Start

– As soon as the print spooler is starting, click the Delete button from the Delete Printer Dialog screen.

– If you selected multiple drivers to delete, you may have to repeat this process until all printer drivers are gone.

ByChris Hall

Detect internet connectivity and reboot router as required

If you’re having issues with your internet connection and finding your Router is dropping Internet at random times, the below windows batch may help alleviate the issue as a temporary measure.

To run this, download a copy of plink.exe from the putty download page and save it to a server running onsite (as an example to C:\admin\plink.exe). Copy the below into a batch file in the same directory and save the file. You can then use Task Scheduler to run the task automatically during the day.

The script pings www.google.com and is the ping fails triggers a reboot on the router.

If needed you could setup this to email using VBS and/or log the reboots in a file by pipping the information out (you can do this by typing “ >> C:\admin\plink_log.txt” without the quotes at the end of the reboot command).

@echo off
ping -n 1 www.google.com
IF ERRORLEVEL 0 GOTO END
echo reboot|”C:\admin\plink.exe” -ssh -pw ******** admin@192.168.1.1 reboot
:END

ByChris Hall

Exchange 2010 Management Console and Shell are very slow to load

In most cases, we’ve found Exchange Management Console (EMC) and/or Exchange Management Shell (EMS) by default to load very slowly on PCs. To correct this you can follow the steps below.
Note: The default security options changed in the below are recommended by Microsoft and this can present a risk unless the machine is in a secure environment.

Turn off (Uncheck) “Check for publisher’s certificate revocation” & “Check for server certificate revocation” options on the server/workstations you are starting the EMC on

· In Windows Internet Explorer –> Tools –> Internet Options –> Advanced tab

· In the Security section, uncheck the below two options “Check for publisher’s certificate revocation” & “Check for server certificate revocation”

Based on the default settings in Internet Explorer, the EMC will always try to connect to the Certificate Revocation List (CRL) web site. Exchange examines the CRL list to verify the code signing certificate. This process in most cases take a long time, therefore the delay.

ByChris Hall

Exchange Management Shell – List All Distribution Lists and Members

The below is a script written to output all Distribution Lists (DL) and DL Members to a CSV File.

Note that the variable set in the first line of the script is the CSV Output Location and you should change the line with ‘RemoteExchange.ps1’ to the location of your Exchange directory.

set-variable -name exportCSVFileLocation -value “C:\temp\Export.csv”
Remove-Item “$exportCSVFileLocation”
Cls
echo “”
echo “**********************************************”
echo “Export All Distribution Lists and Users to CSV”
echo “**********************************************”
echo “”
echo “CSV File Output Location: $exportCSVFileLocation”
echo “”
echo “Exporting, Please wait…”
echo “”
. ‘C:\Program Files\Exchange Server\V15\bin\RemoteExchange.ps1’
Connect-ExchangeServer -auto | out-null
foreach ($group in Get-DistributionGroup) { get-distributiongroupmember $group | sort displayname | select-object displayname,recipientType,@{Label=”Group Name”;Expression={“$group”}} | export-csv -append “$exportCSVFileLocation”}
echo “”
echo “Export Complete”
echo “”
pause

ByChris Hall

Exchange Management Shell – Meeting Room Permissions for Automatic Acceptance

If changes need to be made on permissions to be able to book a meeting room, the best way you can affect any changes is through the Exchange Management Shell (EMS).

There are two settings “bookinpolicy” and “requestinpolicy” that need to be updated. The commands need to be run one after another.

Firstly, you need to get the existing settings:
get-mailboxcalendarsettings ExecOfficeMeetingRm | fl name, requestinpolicy
get-mailboxcalendarsettings ExecOfficeMeetingRm | fl name, bookinpolicy

Each time you change the setting, it is an “overwrite” process, so you cannot simply add or remove a single name.

The Following is an example from within EMS using the set-mailboxcalendarsettings cmdlet.

set-mailboxcalendarsettings “Meeting Room Name” -AutomateProcessing AutoAccept -RequestInPolicy “user1”, “user2”, “user3”, “user4”, “user5”, “user6”, “user7”
set-mailboxcalendarsettings “Meeting Room Name” -AutomateProcessing AutoAccept -BookInPolicy “user1”, “user2”, “user3”, “user4”, “user5”, “user6”, “user7”

In the above two commands, simply replace the “Meeting Room Name” with your meeting rooms name and replace the userX sections with you username for as many users as required.

To validate the system changes have been made, run the below command:
get-mailboxcalendarsettings “Meeting Room Name” | fl name, bookinpolicy, requestinpolicy

ByChris Hall

How to correctly destroy a session in PHP

To correctly destroy a session in PHP, use the below code. It will destroy all variables, cookies and the session itself.

<?php
// Initialize the session.
// If you are using session_name(“something”), don’t forget it now!
session_start();

// Unset all of the session variables.
$_SESSION = array();

// If it’s desired to kill the session, also delete the session cookie.
// Note: This will destroy the session, and not just the session data!
if (ini_get(“session.use_cookies”)) {
$params = session_get_cookie_params();
setcookie(session_name(), ”, time() – 42000,
$params[“path”], $params[“domain”],
$params[“secure”], $params[“httponly”]
);
}

// Finally, destroy the session.
session_destroy();
?>

ByChris Hall

How to run Control Panel tools by typing a command

To run a Control Panel tool in Windows, type the appropriate command in the Open box or at a command prompt.

NOTE: If you want to run a command from a command prompt, you must do so from the Windows folder. Also, note that your computer may not have all of the tools listed in this article, as your Windows installation may not include all of these components.

 

Accessibility Options       
Add New Hardware     
Add/Remove Programs
Date/Time Properties
Display Properties
FindFast
Fonts Folder  
Internet Properties   
Joystick Properties   
Keyboard Properties  
Microsoft Exchange  
Microsoft Mail Post Office    
Modem Properties     
Mouse Properties    
Multimedia Properties  
Network Properties     
Password Properties    
PC Card          
Printers Folder   
Regional Settings   
Scanners and Cameras
Sound Properties  
System Properties   
control access.cpl
control sysdm.cpl
control appwiz.cpl
control timedate.cpl
control desk.cpl
control findfast.cpl
control fonts
control inetcpl.cpl
control joy.cpl
control main.cpl keyboard
control mlcfg32.cpl
control wgpocpl.cpl
control modem.cpl
control main.cpl
control mmsys.cpl
control netcpl.cpl
control password.cpl
control main.cpl pc card (PCMCIA)
control printers
control intl.cpl
control sticpl.cpl
control mmsys.cpl sounds
control sysdm.cpl

 
Retrieved from:
https://support.microsoft.com/en-us/kb/192806

 

ByChris Hall

Oracle 10g Data Guard listener.ora entries

The following entries must be in the listener.ora file for Data Guard to work successfully, this is needed if DYNAMIC_REGISTRATION_LISTENER is set to OFF and you have manually configured Data Guard via the command line. Oracle 10.2.0.5.6 on Solaris.

(SID_DESC=

(GLOBAL_DBNAME=[sid].world)

(SID_NAME=[sid])

(ORACLE_HOME=/opt/oracle/product/10.2.0))

 

(SID_DESC=

(GLOBAL_DBNAME=[sid]_xpt.world)

(SID_NAME=[sid])

(ORACLE_HOME=/opt/oracle/product/10.2.0))

 

(SID_DESC=

(GLOBAL_DBNAME=[sid]_DGMGRL.world)

(SID_NAME=[sid])

(ORACLE_HOME=/opt/oracle/product/10.2.0))

 

(SID_DESC=

(GLOBAL_DBNAME=[sid]_dgb.world)

(SID_NAME=[sid])

(ORACLE_HOME=/opt/oracle/product/10.2.0))