目录

前言

这绝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脚本的更多相关文章

  1. windows开机自启动bat脚本设置

    群里有朋友问到windows下如何设计开机自启动的脚本,一般而言小鱼大多还是在linux环境下运维,windows的bat了解的很少,windows运行机制也不是特别了解,不过既然朋友问到这个问题,虽 ...

  2. [Winform]setupfactory打包时添加开机自启动的脚本

    摘要 如果有这样的需求,需要软件开机自启动,该如何做呢?开机自启动的做法,就是修改注册表,将你的exe注册到注册表Run节点下. setupfactory 在安装的时候需要以管理员身份运行,这样可以保 ...

  3. linux_设置开机自启动程序脚本

    设置开机自启动

  4. CentOS -- 添加开机自启动 命令 脚本

    如果只是添加一条开机启动的命令: 1. chmod +x /etc/rc.d/rc.local 2. 将命令写到 /etc/rc.d/rc.local 这个文件中 3. reboot

  5. Linux开机自启动脚本

    将需要开机自启动的脚本命令写在文件/etc/rc.d/rc.local中即可. 比如需要开机自启动MySql和Apache,则在/etc/rc.d/rc.local文件尾部加入两行命令: system ...

  6. apache 开机自启动脚本设置

    默认我们源码编译安装apache,是不能使用service这个命令来启动的,通常我们启动的命令是: [root@localhost httpd-2.2.16]# /usr/local/apache2/ ...

  7. 将命令添加到shell脚本中然后设置开机自启动

    例如开机自启动nginx 编写一个脚本 #vi /usr/local/Monitor_nginx.sh #!/bin/bash if [ "$(ps -ef | grep "ngi ...

  8. linux添加开机自启动脚本示例详解

    linux下(以RedHat为范本)添加开机自启动脚本有两种方法,先来简单的; 一.在/etc/rc.local中添加如果不想将脚本粘来粘去,或创建链接什么的,则:step1. 先修改好脚本,使其所有 ...

  9. Ubuntu编写开机自启动脚本(转载)

    From:http://blog.csdn.net/marujunyy/article/details/8466255 1.首先编写一个简单的shell脚本test.sh #! /bin/bash e ...

随机推荐

  1. rem和css3的相关知识点

    ☆☆☆rem和css3的相关知识点☆☆☆ 一. Web front-end development engineer rem是根据页面的根元素的font-size的一个相对的单位,即 html{ fo ...

  2. linux安装mysql8(完整图文笔记)

    基本命令 安装 : yum install mysql-community-server 启动 : service mysqld start/restart 停止 : service mysqld s ...

  3. C#GC垃圾回收和析构函数和IDisposable的使用

    一,什么是GC 1,GC是垃圾回收器,一般来说系统会自动检测不会使用的对象或变量进行内存的释放,不需要手动调用,用Collect()就是强制进行垃圾回收,使内存得到及时的释放,让程序效率更高. 2,G ...

  4. 小程序之如和使用view内部组件来进行页面的排版功能

    这篇文章主要介绍了关于小程序之如和使用view内部组件来进行页面的排版功能,有着一定的参考价值,现在分享给大家,有需要的朋友可以参考一下 涉及知识点: 1.垂直排列,水平排列 2.居中对齐 示例: 1 ...

  5. CSS中:first-child伪类

    使用 :first-child 伪类来选择作为某个元素的第一个子元素.这个特定伪类很容易遭到误解,所以有必要举例来说明.考虑以下标记: 如下: html: <div> <p>T ...

  6. 基于TCP/UDP协议的socket

    基于TCP协议的socket tcp是基于链接的,必须先启动服务端,然后再启动客户端去链接服务端 server端 import socket sk = socket.socket() sk.bind( ...

  7. VB程序设计中Combobox的取值问题

    Private a As Double   Private Sub Combo1_Click()    '1位小数,系数用10    a = Combo1.ItemData(Combo1.ListIn ...

  8. Fokker–Planck equation

    Fokker–Planck equation:https://en.wikipedia.org/wiki/Fokker%E2%80%93Planck_equation 随机微分方程:https://e ...

  9. mysql 中文乱码 修改编码 utf8

    在安装完数据库的时候,先不要创建数据库,先去更改字符集设置. show variables like 'character%'; vim /etc/my.cnf   (注意 下面的字段文件内没有时,自 ...

  10. lambda匿名函数sorted排序函数filter过滤函数map映射函数

    lambda函数:表示匿名函数,不需要def来声明,一句话就能搞定. 语法:函数名=lamda 参数:返回值 求10的10次方 f=lambda n:n**n print(f(10)) 注意: 函数名 ...