[Windows 10] How to run script when user click shutdown?

本帖最後由 banang 於 2020-10-11 00:34 編輯

各位師兄,

請問如何 run script when user click shutdown ?

I try the following under Local Group Policy but the the script fails to run.

Motherboard: Asrock B450M-HDV 4.0
Windows 10 Pro 2004
Shutdown script.gif

要知你 run 啲乜同出咩 error

TOP

回覆 2# tunster

Below are the commands of the script file:

ipconfig /displaydns > h:\script\displaydns.txt
for /f "tokens=1-5 delims=/ " %%d in ("%date%") do rename "displaydns.txt" %%e-%%f-%%g.txt

TOP

回覆  tunster

Below are the commands of the script file:

ipconfig /displaydns > h:\script\display ...
banang 發表於 2020-10-11 11:12

你個 h drive 係 network drive 定本機 ?
你有無試下用簡單 d 既 command , 再 save 係本機去確認 shutdown script 有無正常 run 到 , 慢慢再排除問題 ?

e.g.
echo Testing > C:\Test\test.txt

當然你係個 C Drive 要開定個 "Test" folder 先

TOP

師兄,

h: is just one of the local drive in a local SSD.

Simple commands like PAUSE or ECHO doesn't seem to work. No pause, no echo, no file created from piping to > local drive.

TOP

本帖最後由 觀星是答案 於 2020-10-12 12:23 編輯
師兄,

h: is just one of the local drive in a local SSD.

Simple commands like PAUSE or ECHO doesn' ...
banang 發表於 2020-10-12 10:19

Permission 有無試 set 做 everyone full access ?

TOP

我直接將個 shutdown script 放係 default 既 scrip folder , 直接 run (唔用 cmd /c) , 可以成功行到

Untitled.png

TOP

你個 script 放 system32, 你肯定你有 permission?

試下放 C:\temp 哩啲無咁密嘅 folder 試下啲簡單 command 先

TOP

你要的可能係logoff script而唔係shutdown script

TOP

回覆 8# tunster
師兄,

I use local admin, to keep it simple, I put it in local folder C:\temp. Run it manually, no problem.

Somehow it still doesn't work during after I click shutdown.
Shutdown local script.gif

TOP