设置开机后自动运行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路径下的程序

 

转载于:https://www.cnblogs.com/tinysun/p/6732973.html

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值