Chinaunix首页 | 论坛 | 博客
  • 博客访问: 412454
  • 博文数量: 78
  • 博客积分: 1527
  • 博客等级: 上尉
  • 技术积分: 830
  • 用 户 组: 普通用户
  • 注册时间: 2006-03-27 20:57
文章分类

全部博文(78)

文章存档

2011年(1)

2008年(12)

2007年(53)

2006年(12)

我的朋友

分类: WINDOWS

2008-01-05 17:24:53

ANSYS安装自动配置批处理脚本
版权声明:转载时请以超链接形式标明文章原始出处和作者信息
(村长也来个版权声明玩玩 ^_^)
  同学和我每次重装完XP系统后,总得重装ANSYS,进行很多没有水平的重复性操作,烦琐至极。上两天,突发奇想,写个批处理脚本,双击就能完成相关操作岂不是更好?
   村长会一点点sed,用sed写了如下的批处理脚本。
echo off
echo SERVER >tempfile
ipconfig /all |sed -n "/Host Name/p"|sed "s/-//g"|sed "s/.*: \(.*\)/\1/g" >>tempfile
ipconfig /all |sed -n "/Physical Address/p"|sed "s/-//g"|sed "s/.*: \(.*\)/\1/g" >>tempfile
echo 1055 >>tempfile
sed -i "N;N;N;s/\n/\t/g" tempfile
sed "1d" ansys.dat>>tempfile
copy tempfile ansys.dat
ansys.exe -i ansys.dat -o license.dat
if not exist "C:\Program Files\Ansys Inc\Shared Files\Licensing". mkdir "C:\Program Files\Ansys Inc\Shared Files\Licensing"
copy license.dat "C:\Program Files\Ansys Inc\Shared Files\Licensing"
echo Windows Registry Editor Version 5.00 >tempfile
echo [HKEY_CURRENT_USER\Environment] >>tempfile
echo -ANSYSLMD_LICENSE_FILE- = -1055@ >temp
ipconfig /all |sed -n "/Host Name/p"|sed "s/-//g"|sed "s/.*: \(.*\)/\1/g" >>temp
echo - >>temp
sed -i "s/-/\"/g" temp
sed -i -e "2N" -e "s/\n//" temp
sed -i -e "N" -e "s/\n//" temp
sed -i "s/ //g" temp
type temp>>tempfile
reg import tempfile
del tempfile
del temp
del ansys.txt
 
  虽能完成任务,但费了村长太多的时间,而且脚本不够简洁,使用者还得下载sed,让村长很不满意。因此,在linuxsir发了一个帖子,请教高手优化,得到了lxmxn 朋友的帮助。在此感谢lxmxn。村长又写出了下面的脚本:

rem this bat file is used to create keygen file and add user environment ANSYSLMD_LICENSE_FILE automatically.

@echo off & Setlocal EnableDelayedExpansion

rem get mac address from the output of command GETMAC;
for /f %%a in ('getmac /nh') do set mac=%%a

:: get rid of charactor - in %mac%
set mac=%mac:-=%

rem replace the computer name and mac in ansys.dat with yours

echo SERVER %ComputerName% %mac% 1055>tempfile
(for /f "delims=: tokens=1*" %%a in ('findstr /n .* ansys.dat') do (
    if %%a geq 2 echo\%%b
))>>tempfile

:: create keygen file

ansys.exe -i tempfile -o license.dat

:: copy keygen file to "C:\Program Files\Ansys Inc\Shared Files\Licensing"

if not exist "C:\Program Files\Ansys Inc\Shared Files\Licensing". mkdir "C:\Program Files\Ansys Inc\Shared Files\Licensing" copy license.dat "C:\Program Files\Ansys Inc\Shared Files\Licensing"

:: add user environment

set regpath=HKEY_CURRENT_USER\Environment
::user environment
:: regpath=HKEY_CURRENT_USER\Environment
reg add "%regpath%" /v "ANSYSLMD_LICENSE_FILE" /d ""


::thank you help
::enjoy yourself
:: by cunzhang@HEU

村长提示:你可以下载该脚本,解压到ansys.dat所在目录。然后运行该脚本即可。
 
这次完全使用Win下的命令,同时脚本也得到了很大的简化!现在你只需要安装好ANSYS和ANSYS FlEXlm licence manager,然后运行该脚本。再启动“程序->ANSYS FLEXlm License Manager->ANSLIC_ADMIN Utility,点击 Start the License Manager ”,下面的status将显示 “License manager running”。这说明ANSYS的license服务已经启动成功。这时便可以启动ANSYS了。
 
Enjoy yourself!
村长
2008-1-5 17:24:01
阅读(4749) | 评论(1) | 转发(0) |
给主人留下些什么吧!~~

chinaunix网友2009-05-17 14:22:26

支持 不过貌似用处不大