Git Product home page Git Product logo

elevate's Introduction

Elevate

Run a windows command or program a la Run program as an administrator

Example

elevate.exe cmd /c mklink /D up ..

Will run “cmd /c mklink /D up ..” with elevated privileges in order to create a symbolic link.

Need for Elevate

Windows UAC User Account Control improves security for Windows users, at the cost of increase complexity, inconvenience, and frequent frustration for software developers. However, even though the user can adjust the level of security of UAC, or even turn it off, there are still some Windows commands and programs that still require Administrative privileges regardless of UAC settings.

While it is possible to configure programs to “Always Run as an Administrator,” this requires manual intervention on the user's part. Usually software developers get tripped up when they are are trying to automate processes, such as unit test, and the process will fail because someone has forgotten to set a program's properties with “Always Run as an Administrator.”

One way around this is to embed the necessary privileges in the Windows .exe or .dll file via the [Application Manifests](http://msdn.microsoft.com/en-us/library/aa374191(v=vs.85\).aspx), for example

  <?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.v2">
      <security>
        <requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
          <!--
            The presence of the "requestedExecutionLevel" node will disable
            file and registry virtualization on Vista.

            Use the "level" attribute to specify the User Account Control level:
              asInvoker            = Never prompt for elevation
              requireAdministrator = Always prompt for elevation
              highestAvailable     = Prompt for elevation when started by administrator, but
                                     do not prompt for administrator password when started by
                                     standard user.
            -->
          <requestedExecutionLevel level="requireAdministrator"/>
        </requestedPrivileges>
      </security>
    </trustInfo>
  </assembly>

For example, the program elevate.exe has this manifest bundled into it, so it will always behave as if a use manually enabled the program properties “Always Run as an Administrator.”

  • Use Case: Automated Unit Tests

    Often automated tests use test fixtures to setup the environment for the Unit Under Test. If one of the things the test fixture needs to do is create a Symbolic Link then this will generally fail on Windows because creating symbolic links can introduce security vulnerabilities into the system. Consequently, this can only be done running as the Administrator user.

elevate's People

Contributors

kolotyluk avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.