当前位置:首页 » 编程软件 » 菜单脚本怎么写

菜单脚本怎么写

发布时间: 2023-09-07 18:11:48

A. BAT 新建开始菜单目录、快捷方式脚本

@echo off
set shortCutPath=C:\Documents and Settings\All Users\“开始”菜单\程序\机器猫
set shortCutName=cat
set shortCutSource=D:\Program Files\machine cat\cat.exe
md "%shortCutPath%"
echo Dim WshShell,Shortcut>>tmp.vbs
echo Dim path,fso>>tmp.vbs
echo path="%shortCutSource%">>tmp.vbs
echo Set fso=CreateObject("Scripting.FileSystemObject")>>tmp.vbs
echo Set WshShell=WScript.CreateObject("WScript.Shell")>>tmp.vbs
echo Set Shortcut=WshShell.CreateShortCut("%shortCutPath%\%shortCutName%.lnk")>>tmp.vbs
echo Shortcut.TargetPath=path>>tmp.vbs
echo Shortcut.Save>>tmp.vbs
"%SystemRoot%\System32\WScript.exe" tmp.vbs
@del /f /s /q tmp.vbs

以上保存为.bat文件即可。

另外,第2、3、4行的
set shortCutPath.........
set shortCutName........
set shortCutSource............
这三行等分别存入的是:
快捷方式路径(不含文件名)、快捷方式名字、源文件路径(含文件名),
只要修改对应的内容,就可以更改创建快捷方式的位置,文件名,以及指向的源文件。

B. 结合一些简单的LINUX命令编写一个脚本实现简单的菜单功能,掌握IFwhile,for等条件和循环语句使用

供参考:(一),实现菜单操作;
(二),实现新增用户,删除用户,修改用户名,修改用户密码。
while :
do
cat << EOF
================================================================= Welcome to use the shellscripts 1.Add user
2.Delete user
3.Modify username
4.Modify password
q.Quit=================================================================
EOF read -p "Please enter your choice: " CHOICE
case $CHOICE in
1) read -p "Please enter username: " USERNAME
useradd $USERNAME && echo "User create ok!"
;;
2) read -p "Please enter username: " USERNAME
userdel -r $USERNAME && echo "User delete ok"
;;
3)
read -p "Please enter olsername: " USERNAME1 read -p "Please enter newusername: " USERNAME2
usermod -l $USERNAME2 $USERNAME1 && echo "Username modify ok"
;;
4)
read -p "Please enter username: " USERNAME
passwd $USERNAME
;;
q|Q)
clear
exit 0
;;
*)
clear
;;
esac
done

热点内容
地产网站源码 发布:2025-07-09 14:07:08 浏览:71
sdk3000编译环境 发布:2025-07-09 14:06:09 浏览:978
烟灰奇迹脚本 发布:2025-07-09 14:02:27 浏览:75
游戏王服务器地址 发布:2025-07-09 13:38:07 浏览:771
双加密狗 发布:2025-07-09 13:26:51 浏览:471
1加5t买什么配置合适 发布:2025-07-09 13:17:51 浏览:540
mssql分页存储过程 发布:2025-07-09 13:17:00 浏览:271
cpython模块扩展 发布:2025-07-09 13:16:11 浏览:95
linux安装mysql步骤 发布:2025-07-09 13:02:48 浏览:158
ant编译flex 发布:2025-07-09 12:57:10 浏览:787