什么是C#编写批处理脚本的好办法? [英] What's a good way to write batch scripts in C#?

查看:169
本文介绍了什么是C#编写批处理脚本的好办法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想C#编写简单的脚本。东西,我通常会使用.bat或4NT .btm的文件。复制文件,文本分析,要求用户输入,等等。相当简单,但就在一个批处理文件做这东西真的很难(如无例外)。

I would like to write simple scripts in C#. Stuff I would normally use .bat or 4NT .btm files for. Copying files, parsing text, asking user input, and so on. Fairly simple but doing this stuff right in a batch file is really hard (no exceptions for example).

我熟悉像AxScript命令行脚本包装,以便让我的存在方式的一部分。什么,我缺少的是简单的文件操作框架。我希望能够做的cd(..),复制(SRCFILE,destFile)类型的功能。

I'm familiar with command line "scripting" wrappers like AxScript so that gets me part of the way there. What I'm missing is the easy file-manipulation framework. I want to be able to do cd(".."), copy(srcFile, destFile) type functionality.

工具我都试过:


  • NANT,这是我们在构建过程中使用。没有一个良好的脚本工具。疯狂冗长的XML语法,并添加一个简单的功能,你必须写一个扩展集。不能这样做内联。

  • NANT, which we use in our build process. Not a good scripting tool. Insanely verbose XML syntax and to add a simple function you must write an extension assembly. Can't do it inline.

的PowerShell。看起来不错,但我一直没能切换到这作为我的主外壳。从4NT太多的差异。无论我做什么需要从一个普通的命令提示符下运行,而不需要特殊的shell通过运行它。可以的PowerShell作为脚本执行?

PowerShell. Looks great, but I just haven't been able to switch over to this as my primary shell. Too many differences from 4NT. Whatever I do needs to run from an ordinary command prompt and not require a special shell to run it through. Can PowerShell be used as a script executor?

的Perl / Python的/红宝石。真的很讨厌学习一种全新的语言和框架只是做批处理文件操作。一直没能奉献我需要做这个的时候。此外,我们为我们的工具链99%。NET店,我真的想利用我们现有的经验和codeBase的。

Perl/Python/Ruby. Really hate learning an entirely new language and framework just to do batch file operations. Haven't been able to dedicate the time I need to do this. Plus, we're a 99% .NET shop for our toolchain and I really want to leverage our existing experience and codebase.

是否有框架外面,试图解决做一个批处理文件,在C#您已使用?这个问题

Are there frameworks out there that are trying to solve this problem of "make a batch file in C#" that you have used?

我想C#/。NET的具有典型的cmd.exe shell语言的直接模式类型的功能的能力。我是独自一人在想这样的事情?

I want the power of C#/.NET with the immediate-mode type functionality of a typical cmd.exe shell language. Am I alone in wanting something like this?

推荐答案

我会尝试,并得到了PowerShell的焦虑,因为它是未来的壳。所有走出微软的软件都使用它作为自己的管理界面,尤其是2.0版是可笑有用的。

I would try to get over the PowerShell anxiety because it is the shell of the future. All of the software coming out of Microsoft is using it as their management interface and especially version 2.0 is ridiculously useful.

我是一个C#开发的大部分时间,但PowerShell的解决了该临时项目的整个WindowsApplication42的问题只是堆放。 PowerShell的让你完全访问.NET框架在命令行shell因此,即使你不知道如何做在PowerShell中,你最有可能知道如何做到这一点的.NET。

I'm a C# developer most of the time but PowerShell has solved that whole "WindowsApplication42" problem of temp projects just piling up. PowerShell gives you full access to the .NET framework in a command line shell so even if you don't know how to do something in PowerShell, you most likely know how to do it in .NET.

这篇关于什么是C#编写批处理脚本的好办法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆