GithubHelp home page GithubHelp logo

ps.cmd's Introduction

Ps.cmd

A batch file wrapper for PowerShell scripts.

Why ?

After I had written dozens of wrappers like this one (and each time losing my hair again and again debugging paths, error codes or why the damn thing didn't work when called from Task Scheduler) I decided to write the "last" one to rule them all.

Usage

Rename the Ps.cmd script to the same name of your .ps1 file and put it in the same folder.

Alternatively, you may use Ps-Map-Switches.cmd if you need to replace every / for - in your .ps1 call.

Features

  • Bypass execution policy.
  • Pass command-line arguments to Powershell script.
  • Preserves ERRORLEVEL returned from Powershell script.
  • Works with "Run as administrator"
  • Works with Windows Task Scheduler
  • When running from Windows Explorer, pauses the script execution in case of error (allows you to see the error message).
    • Doesn't pause when called directly from a cmd prompt.

Please see the Samples folder. Try to run Hello.cmd and Error.cmd double-clicking it from Windows Explorer. Then run them again from command prompt.

C:\samples>hello
Hello, world!

C:\samples>hello mom
Hello, mom!

C:\samples>echo %ERRORLEVEL%
0

C:\samples>error
Something bad happened!

C:\samples>echo %ERRORLEVEL%
3

A Plea

Please, don't use .bat extension for your cmd.exe scripts.

ps.cmd's People

Contributors

fdcastel avatar

Watchers

James Cloos 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.