Tuesday, November 9, 2010

Shell Command - Remove SVN Folders

The Subversion source control client maintains your local state in hidden folders named .svn inside your project, which can be a problem if you want to copy or share the project directory. This REG file adds "Delete SVN Folders" to the context menu for folders. When you select it, it removes all folders named .svn inside the folder and it's children (it does nothing if the project's not under Subversion source control.

I'm not going to bother explaining reg file installation here - I figure if you're using SVN, you're good with reg files.

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Folder\shell\DeleteSVN]
@="Delete SVN Folders"

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Folder\shell\DeleteSVN\command]
@="cmd.exe /c \"TITLE Removing SVN Folders in %1 && COLOR 9A && FOR /r \"%1\" %%f IN (.svn) DO RD /s /q \"%%f\" \""

I got the idea from Wyatt Preul's post comparing Powershell and Command Prompt commands to delete SVN directories, so if you'd like to do this manually take a look at his scripts.


Wednesday, October 27, 2010

How to add a manifest to a legacy application.

How to add a manifest to a legacy application (which you cannot or will not recompile)

I used mt.exe from Windows SDK
"C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin\mt.exe"
to add a manifest to an existing legacy exe to make it Run As Administrator (with elevated privileges) on UAC enabled systems (Vista, Win7 , Win 2008 ...). Here's how:

1)Got a legacy exe file named KSDiag.exe
2)In the same folder create a text file named KSDiag.exe.manifest
3)Put the following lines into the text file:

[?xml version="1.0" encoding="UTF-8" standalone="yes"?]
[assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"]
[trustInfo xmlns="urn:schemas-microsoft-com:asm.v3"]
[security]
[requestedPrivileges]
[requestedExecutionLevel
level="requireAdministrator"
uiAccess="False"/]
[/requestedPrivileges]
[/security]
[/trustInfo]
[/assembly]

Replacing [ with LessThan and ] with GreaterThan


4) Run command:
mt.exe /manifest KSDiag.exe.manifest /outputresource:KSDiag.exe;1

(1 for an EXE, 2 for a DLL
mt.exe –manifest MyApp.exe.manifest -outputresource:MyApp.exe;1
or
mt.exe –manifest MyLibrary.dll.manifest -outputresource:MyLibrary.dll;2
See also: http://msdn.microsoft.com/en-us/library/ms235591.aspx
http://msdn.microsoft.com/en-us/library/aa375649(VS.85).aspx )

Now KSDiag.exe has the manifest added to its resource section. On a UAC enabled OS it gets the shield icon and you get the administrator prompt when you try to run it.
Of course if the file was signed to start with you'll have to resign it.

Yours truly
Klaus Bjorn Jensen
PS (Resource Tuner http://www.restuner.com can do loads of nice stuff.)