設置開機后自動運行powershell腳本攻略


1. 修改注冊表

Open Registry Editor, add a startup item 
i. Locate the path“HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run” 
Create a string value name Shadow 

 

ii. Right click Shadow and choose Modify… 

 

 iii. Add the path of the cmd file above. For example: C:\Users\userName\Desktop\Shadow.cmd, and OK.

 注意,這里的地址可以自己定義,也就是將來"Shadow.cmd"存放的位置

 

 

2.寫批處理

Open a notepad and paste the command below (This file will invoke PowerShell script) 
下面這段代碼的意思是,打開powershell,采用unrestricted形式(否則無法執行腳本),執行C:\Windows\Drives\sucks.ps1腳本。

 
@set Path=%Path%;%SystemRoot%\system32\WindowsPowerShell\v1.0\& powershell -ExecutionPolicy Unrestricted "C:\Windows\Drives\sucks.ps1"
exit

 

3.寫powershell腳本

打開一個txt文件,寫入powershell腳本,並保存為.ps1格式文件,存放在步驟2中提到的路徑(本文中為C:\Windows\Drives\)

 

#requires -Version 1
  write-host "running....please wait 1 min"
  Start-Sleep -s (60)
  Start-Process -FilePath "C:\Users\neousys\Desktop\微光本地端-內測版"

 

上面這段腳本的意思是

1.在屏幕上顯示"running....please wait 1 min"

2.等待60s

3.運行xxx路徑下的程序

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM