开机自启动Powershell脚本
目录
前言
这绝B是个非常受用的技能。
修改注册表
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.
写批处理
Open a notepad and paste the command below (This file will invoke PowerShell script)
执行当前目录下同名的.ps1脚本。
@set Path=%Path%;%SystemRoot%\system32\WindowsPowerShell\v1.0\ & powershell -ExecutionPolicy Unrestricted -NoProfile %~dpn0.ps1
exit
Save as shadow.cmd on your desktop.
注意:并不需要照搬上面的内容,你可以在.cmd这个文件中自定义希望被调用的Powershell脚本,就可以实现开机自启动Powershell脚本了。后面的内容作为实验记录,仅供参考。
以管理员方式打开Posershell程序
Open a notepad and paste the command below (This file will open PowerShell with administrator permission)
Start-Process "$PSHOME\powershell.exe" -Verb runas
Save as shadow.ps1 on your desktop.
修改PS-profile
Create a profile for current user’s PowerShell (This file will import module when PowerShell start)
$a= (Get-Host).UI.RawUI
$a.WindowTitle="MCShadow"
$a.ForegroundColor="Green"
$b=$a.WindowSize
$b.Width="120"
$b.Height="57"
$a.WindowSize=$b
Import-Module D:\ShadowMod.psm1
Start-Shadow
Write-Host "Imported Module ShadowMod.psm1"
Write-Host "Ready to use Start or Stop Shadow”
Save as Profile.ps1 under this path “C:\Users\userName\Documents\WindowsPowerShell”, if you can’t find this folder, please create it by manual.
最后
后部分的内容是对PS-profile的实验内容,自启动的原理还是在于注册表的修改和.cmd文件对指定PSScript的调用。 :-)
开机自启动Powershell脚本的更多相关文章
- windows开机自启动bat脚本设置
群里有朋友问到windows下如何设计开机自启动的脚本,一般而言小鱼大多还是在linux环境下运维,windows的bat了解的很少,windows运行机制也不是特别了解,不过既然朋友问到这个问题,虽 ...
- [Winform]setupfactory打包时添加开机自启动的脚本
摘要 如果有这样的需求,需要软件开机自启动,该如何做呢?开机自启动的做法,就是修改注册表,将你的exe注册到注册表Run节点下. setupfactory 在安装的时候需要以管理员身份运行,这样可以保 ...
- linux_设置开机自启动程序脚本
设置开机自启动
- CentOS -- 添加开机自启动 命令 脚本
如果只是添加一条开机启动的命令: 1. chmod +x /etc/rc.d/rc.local 2. 将命令写到 /etc/rc.d/rc.local 这个文件中 3. reboot
- Linux开机自启动脚本
将需要开机自启动的脚本命令写在文件/etc/rc.d/rc.local中即可. 比如需要开机自启动MySql和Apache,则在/etc/rc.d/rc.local文件尾部加入两行命令: system ...
- apache 开机自启动脚本设置
默认我们源码编译安装apache,是不能使用service这个命令来启动的,通常我们启动的命令是: [root@localhost httpd-2.2.16]# /usr/local/apache2/ ...
- 将命令添加到shell脚本中然后设置开机自启动
例如开机自启动nginx 编写一个脚本 #vi /usr/local/Monitor_nginx.sh #!/bin/bash if [ "$(ps -ef | grep "ngi ...
- linux添加开机自启动脚本示例详解
linux下(以RedHat为范本)添加开机自启动脚本有两种方法,先来简单的; 一.在/etc/rc.local中添加如果不想将脚本粘来粘去,或创建链接什么的,则:step1. 先修改好脚本,使其所有 ...
- Ubuntu编写开机自启动脚本(转载)
From:http://blog.csdn.net/marujunyy/article/details/8466255 1.首先编写一个简单的shell脚本test.sh #! /bin/bash e ...
随机推荐
- @Transactional实现原理
Transactional是spring中定义的事务注解,在方法或类上加该注解开启事务.主要是通过反射获取bean的注解信息,利用AOP对编程式事务进行封装实现.AOP对事务的封装可以看我的这篇文章的 ...
- Redis主从架构核心原理
Redis-Cluster工作原理: redis集群内置了16384个哈希槽,当需要在 Redis 集群中放置一个 key-value 时,redis 先对 key 使用 crc16 算法算出一个结果 ...
- 关于使用iframe的父子页面进行简单的相互传值
当一个页面使用了iframe作为嵌套时,如何想要将父页面的数据传给iframe子页面,那iframe所指向的呢个子页面是怎么获取呢,又或者子页面的数据要给父页面使用,那么父页面又如何获取子页面的数据呢 ...
- linux用户管理(useradd、userdel、usermod、groupadd、groupdel、chage、passwd、chpasswd)
一.用户账户配置文件介绍 /etc/passwd 用户账户信息文件/etc/shadow 用户账户密码文件/etc/group 用户组信息文件/etc/gshadow 用户组密码所在文件(基本废弃)/ ...
- WithEvents的一些用法
WithEvents的一些用法说明:1.WithEvents是指定一个或多个已声明成员变量引用可引发事件的类的实例.2.当某个变量是使用 WithEvents 定义时,可以用声明方式指定某个方法使用 ...
- Codeforces 939 时区模拟 三分
A #include <bits/stdc++.h> #define PI acos(-1.0) #define mem(a,b) memset((a),b,sizeof(a)) #def ...
- Ubuntu 16.04 安装摄像头驱动usb_cam
!!需要在ROS平台上安装 ROS见 https://www.cnblogs.com/haijian/p/8782560.html cd ~/catkin_ws/src 下载usb_cam包 gi ...
- Flutter-Radio單選框
Container( child: Radio<String>( value: "男", activeColor: Colors.red,//激活時的顏色 groupV ...
- TLS漏洞:超过50万个电子邮件服务器容易受黑客攻击,太可怕了
2019年在流行的开源Exim电子邮件服务器软件中发现了一个关键的远程执行代码漏洞,至少有超过50万个电子邮件服务器容易受到远程黑客攻击.Exim是一种广泛使用的开源邮件传输代理(MTA)软件,为类似 ...
- 【01】Python 环境变量、条件判断、循环、基本运算符
1 环境变量 1.1 Windows下环境变量 系统变量Path中要加入Python安装路径: C:\xxxx\Python36;C:\xxxx\Python36\Scripts; 2 条件判断 2. ...