Privileged Command Prompt

Windows Vista ushers in the concept of Limited User Account (LUA) to the Microsoft world. The rest of the world has always known this practice, but now we too can rest assured that privileged operations will only occur when we elevate our account privileges.

When you attempt to perform a privileged operation in Vista e.g. copy a file to %SystemRoot%, User Account Control (UAC) challenges you for an administrative password. Great stuff.

What if the privileged operation you wish to perform is from an existing command prompt? In Linux (and Mac OS X) there is sudo. Given proper configuration you can precede a privileged command with "sudo" and it will succeed. This feature does not (yet) exist in Vista.

The attached tool - yacmd - provides "sudo" functionality in so far as enabling privileged commands to succeed from an existing command prompt. It does this by taking advantage of a .NET Runtime feature whereby a process execution-level can be requested. Any .NET executable module can have a manifest file e.g. yacmd.exe.manifest containing the following:

<?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"/>
                        </requestedPrivileges>
                </security>
        </trustInfo>
</assembly>

So uncompress yasudo.zip to somewhere in your path and you will have the ability to execute privileged operations from an existing command prompt.

Example usage:

yasudo /c sc stop w3svc
AttachmentSize
yasudo-1.0.zip2.38 KB
yasudo_src-1.0.zip4.15 KB