博客首页 注册 建议与交流 排行榜 加入友情链接
推荐 投诉 搜索: 帮助

PowerShell

努力做中文最好的Windows PowerShell学习基地 本Blog所发表的所有"原创文章", 除特别说明, 均可转载, 转载请保留作者姓名, 链接. 谢谢
   PowerShell.cublog.cn
关于作者  
联系邮箱:
PowerShellCn<AT>hotmail{DOT}com
PowerShellCn<AT>gmail{DOT}com
PowerShell<AT>163{DOT}com

我的分类  




如何在PowerShell中访问cmd的con伪文件

cmd用户可能喜欢使用copy con ...这个命令, con是一个伪文件, 表示接受用户的输入, 并将其存储到文件中.

下面是 Thomas Lee 写的一个小脚本, 脚本历史很悠久了...那时候PowerShell还叫MSH呢.

# CopyfromConsole.msh
# Author Thomas Lee, based on a news posting by an unknown user
# This function copies text from the console and pipes it to a filee
# which gets around MSH's lack of a CON: (or abilty to do copy con: <file>!)
# if you call this without any paramaters, out-file prompts for a filename
 
 
Function CopyfromConsole {
param ($outfile="")
 
if ($outfile-eq"")
{
    [system.console]::in.readtoend() | out-file
}
Else
{
    [system.console]::in.readtoend() | out-file$outfile
}
}
 
set-alias copyconCopyfromConsole

 原文地址 http://tfl09.blogspot.com/2005/10/monad-and-command-console.html
 TAG PowerShell
 发表于: 2008-07-04,修改于: 2008-07-04 21:50 已浏览234次,有评论0条 推荐 投诉

  网友评论

  发表评论



Copyright © 2001-2006 ChinaUnix.net All Rights Reserved

感谢所有关心和支持过ChinaUnix的朋友们
页面生成时间:2.46206

京ICP证041476号