Mikael Blomqvist

Change Shutdown Setting

When doing automated reboots using shutdown.exe in my scripts i sometimes need to change back the default shutdown option so the user will have “Shutdown” as the default selection in the shutdown box.

The shutdown setting determining the default shutdown option – (log off, shutdown, restart, standby, hibernate, disconnect) can be found in the registry under current user settings.

Key: HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer
Value: Shutdown Setting
Type: REG_DWORD
Radix: Hex
Data: 00000002

The possible values for Shutdown Setting are:

00000001 = Log Off
00000002 = Shut Down
00000004 = Restart
00000010 = Stand By
00000020 = Stand By (with wakeup events disabled)
00000040 = Hibernate
00000080 = Disconnect (only available in Terminal Services sessions)

Slipstream updates into your Office 2007 installation

I recently had to update a standard Office 2007 installation with SP2. This is easily done with a few commandlines assuming that you have both downloaded the SP2 update and have the Office 2007 installation files already avaliable.

Locate the Updates folder among your Office 2007 installation files. This is the folder where we want the SP2 files to end up. In my example the path to the updates folder is :

E:\Office2007\Updates

I placed the SP2 update in a temporary folder:

E:\Temp\Office2007-SP2-Update\office2007sp2-kb953195-fullfile-da-dk.exe

To extract the SP2 update and thereby slipsteam the SP2 update into the Office 2007 installation simply type the following:

E:\Temp\Office2007-SP2-Update\office2007sp2-kb953195-fullfile-da-dk.exe /extract:”E:\Office2007\Updates”

Accept the licence agreement and follow the steps until you get a confirmation that the installation is complete.

Now you are ready to install Office 2007 SP2.

If you want to slipsteam other Windows updates into your Office 2007 installation files simply repeat the steps above only by replacing the update you want to slipsteam.

Using SubInACL to grant permissions to a folder and its subfolders and files

Recently i had to delete a lot of temporary folders on a large number of domain computers. A GPO had caused a number of folders to be created in the root of C each time a user logged onto a computer. After having sorted the GPO i had to find a way to delete all the folders again. The tricky part was that the folders had different owners and thus different permissions assigned so they could not all be deleted by the current user.

Microsofts command-line tool SubInACL proved to be exactly the tool for the job and i could easily make a vbs script which could do the cleanup job for me at logon – no matter who was logged on.

I simply used SubInACL to give the current user Full Access to all the folders and their subfolders and files by looping through the folder structure and subsequently deleting the folders which matched my deleting criteria.

The syntax i used to give the current user full access a folder and its subfolders and files was this:

subinacl.exe /verbose=1 /subdirectories c:\folder\*.* /grant=Current user=F

Script to delete print driver and printer connection

I recently had to delete a print driver and a printer connection for a large group of computers. I discovered that scripts for exactly that are already is avaliable in windows.

Delete a printer connection:

To delete a printer connection you can use the script called prnmngr.vbs

Delete a print driver:

To delete a print driver you can use the script called prndrvr.vbs

Where can the scripts be found ?

The folder where the tools can be found varies depending on the operating system.

Windows XP:

%windir%\system32\

Windows 7:

%windir\system32\Printing_Admin_Scripts\\

Examples:

To delete a printer connection from the local computer “Printers and Faxes” called Printer1 you use the following command line.

cscript.exe c:\windows\system32\prnmngr.vbs -d -p “Printer1”

To delete a print driver from the local computer you can use the follwing command line. This assumes you are running Windows XP and that the driver name is “Lexmark T654”.

cscript.exe c:\windows\system32\prndrvr.vbs -d -m “Lexmark T654” -v 3 -e “Windows NT x86”.

To run these scripts you need to be part of the local admin group or alternatively run the scripts as one who is member. This can be supplied as part of the command line.

Full documentation:

prnmngr.vbs:  http://technet.microsoft.com/en-us/library/cc725868

prndrvr.vbs: http://technet.microsoft.com/en-us/library/cc754632

Look up the MAC address on a remote computer with GETMAC

To look up a MAC Address on a remote computer you can use the build in windows tool called GETMAC.

Except from the MAC Address GETMAC can also supply information about network protocols and network adapter.

Example:

To get the MAC address of the remote computer PC123456 you simply type the follwing:

getmac /s PC123456

To get full details about adapter name and connection names aswell you simple add the parameter /v.

getmac /s \\PC123456 /v

Full documentation

http://technet.microsoft.com/en-us/library/ff961509

Commands to Control Panel Tools

Instead of clicking through menus to access various tools in the Control Panel it can be faster to just type them in “Run” or command prompt.

Here i listed the ones use the most :

Add/Remove Programs: control appwiz.cpl

Internet Properties: control inetcpl.cpl

Network Properties: control netcpl.cpl

System Properties: control sysdm.cpl

Administrative tools: control admintools

Full list can be found at :

http://support.microsoft.com/kb/192806