Skip to main content

A simple tool to generate a call graph for calls within Windows CMD (batch) files.

Project description

# cmd-call-graph A simple tool to generate a call graph for calls within Windows CMD (batch) files.

It takes the input file as stdin and outputs the resulting file to stdout, outputting logs and errors to stderr.

Usage example from WSL (Windows Subsystem for Linux):

$ python3 cmd-call-graph.py < your-file.cmd > your-file-call-graph.dot 2>log

The resulting dot file can be rendered with any dot renderer. Example with graphviz:

$ sudo apt install graphviz $ dot -Tpng your-file-call-graph.dot > your-file-call-graph.png $ explorer.exe your-file-call-graph.png

## Example

Here is an example CMD script:

@echo off call :foo goto :eof :bar echo “in bar” call :baz call :baz :baz echo “in baz” :foo echo “In foo” goto :bar

This script would generate the following graph:

![call graph](https://github.com/Microsoft/cmd-call-graph/raw/master/examples/example1-noshowall.png)

If the –show-all-calls option is set to True, then the following graph would be generated:

![call graph showall](https://github.com/Microsoft/cmd-call-graph/raw/master/examples/example1.png)

## Why? Sometimes legacy code bases may contain old CMD files. This tool allows to generate a visual representation of the internal calls within the script.

## Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.microsoft.com.

When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.

This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.

## Unit tests Run unit tests from the project root by running:

python3 -m unittest

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cmd-call-graph-0.1.1.tar.gz (4.5 kB view details)

Uploaded Source

Built Distributions

cmd_call_graph-0.1.1-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

cmd_call_graph-0.1.1-py2-none-any.whl (7.2 kB view details)

Uploaded Python 2

File details

Details for the file cmd-call-graph-0.1.1.tar.gz.

File metadata

  • Download URL: cmd-call-graph-0.1.1.tar.gz
  • Upload date:
  • Size: 4.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/40.6.2 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.6

File hashes

Hashes for cmd-call-graph-0.1.1.tar.gz
Algorithm Hash digest
SHA256 2c477b106a9be99933f81a551f00602774426918613c034fe19ecc219a3e2c49
MD5 17868aa8062fe7799c1a0b38c57e8d9e
BLAKE2b-256 23467ea98a668e57ac555641b5d3d603b7232dd233983a7809e2605d8e4ae84a

See more details on using hashes here.

Provenance

File details

Details for the file cmd_call_graph-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: cmd_call_graph-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 6.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/40.6.2 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.6

File hashes

Hashes for cmd_call_graph-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 7c7432ab53329c22b6a7aa4a3bfe46d4c3bef3b4c1f2523eabb50a6f1737d742
MD5 52f95658ffff912f1dd0532bcbf84a10
BLAKE2b-256 39bfffd9633e66d5985eecc5d6116c0a220e42e3ae6eb42953d03b63253d6a0a

See more details on using hashes here.

Provenance

File details

Details for the file cmd_call_graph-0.1.1-py2-none-any.whl.

File metadata

  • Download URL: cmd_call_graph-0.1.1-py2-none-any.whl
  • Upload date:
  • Size: 7.2 kB
  • Tags: Python 2
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/40.6.2 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.6

File hashes

Hashes for cmd_call_graph-0.1.1-py2-none-any.whl
Algorithm Hash digest
SHA256 0f9f98ac0f6b7cf0b3eddc3d82949d573b214016c1081afd6cae30a2a3f867b7
MD5 863c82a0fc5d839ff4a0a0422ce5df08
BLAKE2b-256 b15d615666f22f9b184913a2fd639b0da60845699bb85f04405958d2a8c9e5c5

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page