AutoHotkey Community

It is currently May 26th, 2012, 4:42 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: Print Directory Feature
PostPosted: March 20th, 2008, 3:20 pm 
Offline

Joined: March 26th, 2007, 6:41 pm
Posts: 1
The Print Directory Feature adds or removes the Print Directory feature for folders in Windows XP and in Windows Vista based on Microsoft's article number 321379. http://support.microsoft.com/kb/321379

It can be done manually, but this makes short work of it and it adds a GUI and a method for removing the changes. :wink:

Code:
; Script Function:
;   This script adds or removes the print directory feature from Microsoft Article 321379.
;

#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
#SingleInstance force ;Only one instance of script at a time
#NoTrayIcon ;Removes tray icon display
#EscapeChar ` ;Escape character

; Check for administrator rights which are needed to make these changes before proceeding

If A_IsAdmin = 1
    Goto, IsAdmin
Else
{
    MsgBox, 16, Oops!, You must have administrator rights on this system to run this utility!
    ExitApp
}

IsAdmin:
Sleep, 100

Gui, Add, Button, x16 y17 w180 h50 gAdd, &Add Print Directory Feature
Gui, Add, Button, x16 y87 w180 h50 gRemove, &Remove Print Directory Feature
Gui, Add, Button, x96 y157 w100 h30 gCancel, &Cancel
Gui, Add, Text, x16 y197 w180 h40 +Center, Print Directory Feature Utility v1.0`nWin XP/Vista`nMS Article 321379
Gui, Show, x131 y91 h250 w218, Print Directory Feature
Return

Add:
;Create the printdir.bat file in the systems windows directory for calling
FileAppend, `@echo off`ndir `%1 /-p /o:gn > "`%temp`%\Listing"`nstart /w notepad /p "`%temp`%\Listing"`ndel "`%temp`%\Listing"`nexit, %A_WinDir%\printdir.bat
If ErrorLevel = 1
{
    MsgBox, 16, File Creation Error, There was an error creating the PrintDir.bat file.
    ExitApp
}
Else
    Goto, PrintDirOK
   
PrintDirOk:
Sleep, 100

;Add three registry keys and values to the registry
RegWrite, REG_SZ, HKEY_CLASSES_ROOT, Directory\shell\none, ,
RegWrite, REG_SZ, HKEY_CLASSES_ROOT, Directory\shell\Print_Directory_Listing, , Print Directory Listing
RegWrite, REG_SZ, HKEY_CLASSES_ROOT, Directory\shell\Print_Directory_Listing\command, , printdir.bat
If ErrorLevel = 1
{
    MsgBox, 16, Registry Key Error, There was an error creating the needed registry keys.
    ExitApp
}
Else
    Goto, RegKeyOK
   
RegKeyOk:
Sleep, 100

MsgBox, 64, Success, Print Directory Feature was sucessfully configured!

ExitApp

Remove:
;Delete the printdir.bat file from the systems windows directory
FileDelete, %A_WinDir%\printdir.bat
If ErrorLevel = 1
{
    MsgBox, 16, File Deletion Error, There was an error deleting the PrintDir.bat file from the system Windows directory.
}
Else
    Goto, DelPrintDirOK
   
DelPrintDirOk:
Sleep, 100

;Delete three registry keys and values to the registry
RegDelete, HKEY_CLASSES_ROOT, Directory\shell\Print_Directory_Listing\command,
RegDelete, HKEY_CLASSES_ROOT, Directory\shell\Print_Directory_Listing,
RegDelete, HKEY_CLASSES_ROOT, Directory\shell\none,
If ErrorLevel = 1
{
    MsgBox, 16, Registry Key Error, There was an error deleting the installed registry keys.
}
Else
    Goto, DelRegKeyOK
   
DelRegKeyOk:
Sleep, 100

MsgBox, 64, Success, Print Directory Feature was sucessfully removed!

ExitApp

Cancel:
ExitApp

GuiClose:
ExitApp


I'm still a beginner at AutoHotKey scripts, so my method is probably not the best method, but of course feel free to modify at will or post reply suggestions for myself and others. Enjoy!


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: JamixZol and 13 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group