當前位置:首頁 » 編程軟體 » 菜單腳本怎麼寫

菜單腳本怎麼寫

發布時間: 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

熱點內容
l2l3緩存 發布:2025-02-02 06:56:47 瀏覽:521
為什麼安卓下不了蟲蟲助手 發布:2025-02-02 06:46:47 瀏覽:42
ftp伺服器ui 發布:2025-02-02 06:24:15 瀏覽:102
wifi有多少種密碼 發布:2025-02-02 06:22:06 瀏覽:586
app賬號和密碼忘了怎麼辦啊 發布:2025-02-02 06:21:58 瀏覽:106
map訪問 發布:2025-02-02 06:09:07 瀏覽:825
android獲取應用版本 發布:2025-02-02 05:54:19 瀏覽:747
pythonif比較 發布:2025-02-02 05:24:03 瀏覽:260
已連接的無線網如何知道密碼 發布:2025-02-02 04:53:51 瀏覽:634
android編程入門經典pdf 發布:2025-02-02 04:46:19 瀏覽:59