Re: [請問] 批次檔 按下某個按鈕後執行某些語法

看板EZsoft (小軟體)作者 (想像不出光的影子)時間9年前 (2016/07/23 08:47), 9年前編輯推噓1(101)
留言2則, 1人參與, 最新討論串2/2 (看更多)
這文章張貼看板《EzHotKey》較適合, 這個我好像也是google再修改來的,下次多試一些關鍵字看看, 而且我也有看過換IP設定的小程式,不用自己寫/下指令. 有些指令太長被BBS換行,請小心改回來, 你的網路若不是叫做區域連線,也要改,也有可能是"區域連線 2",或英文名, 若gateway不是x.x.x.254,請自行更改, 內部DNS的IP,請自行更改. @echo off :start cls set input= set /p input=Please Choice 1:OA static ip, 2:Home static ip ,8:DHCP(OA) , 9:DHCP(Internet) ? [1,2,8,9]? if (%input%)==() goto start set input=%input:~0,1% if (%input%)==(9) goto L9 if (%input%)==(8) goto L8 if (%input%)==(2) goto L2 if (%input%)==(1) goto L1 goto start :L1 netsh interface ip set address 區域連線 static 改IP netmask gateway 1 netsh interface ip set dns "區域連線" static 內部DNS的IP goto Lend :L2 netsh interface ip set address 區域連線 static 192.168.1.X 255.255.255.0 192.168.1.254 1 netsh interface ip set dns "區域連線" static 168.95.1.1 netsh interface ip add dns "區域連線" 168.95.192.1 goto Lend :L8 netsh interface ip set address 區域連線 dhcp netsh interface ip set dns "區域連線" static 內部DNS的IP goto Lend :L9 netsh interface ip set address 區域連線 dhcp netsh interface ip set dns "區域連線" static 168.95.1.1 netsh interface ip add dns "區域連線" 168.95.192.1 goto Lend :Lend @echo on ipconfig @pause ※ 引述《HumuHumu (呼姆呼姆)》之銘言: : 小弟我是批次檔菜鳥,對指令完全沒概念,GOOGLE也不知道關鍵字如何下手 : 因此來版上請教 : 我的需求如下: : 因為小弟的筆電時常宿舍、Lab、家裡到處跑,但是這三個地方的網路IPV4設定都不一樣 : 為了不想要每次插上網路線後都要重新去控制台設定IP,因此想要寫個簡單的批次檔,一 : 按下某個按衂後就自動更改設定 : 至於更改IP的批次檔語法我已經在GOOGLE有找到了 : 目前我的需求是,我想要把1.家裡 2.Lab 3.宿舍 三個地方的不同UP都包在一個批次檔裡 : 當我打開批次檔後,他會提示我按下 1 或 2 或 3 然後分別套用家裡 Lab 宿舍 的IP設定 : 但我不知道要如何寫出這種按下某個按鈕執行某些語法的互動式寫法 : 感謝大家了 : PS另外我想請問,有沒有辦法可以讓左鍵點兩下打開批次檔時,效果會等同於 : "右鍵→以系統管理員身分執行" -- 想像不出光的影子 -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 111.243.57.43 ※ 文章網址: https://www.ptt.cc/bbs/EZsoft/M.1469234861.A.F97.html ※ 編輯: fotumbra (111.243.57.43), 07/23/2016 08:56:57

07/23 09:53, , 1F
可以另外貼到 http://pastebin.com/ 就不用怕被斷行
07/23 09:53, 1F

07/23 09:54, , 2F
設定 Syntax Highlighting 選 Batch 還能直接下載成 bat 檔
07/23 09:54, 2F
文章代碼(AID): #1Nahwj-N (EZsoft)
文章代碼(AID): #1Nahwj-N (EZsoft)