November 13, 2012

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