目录

前言

这绝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. C#设计模式:解释器模式(Interpreter Pattern)

    一,C#设计模式:解释器模式(Interpreter Pattern) 1,解释器模式的应用场合是Interpreter模式应用中的难点,只有满足“业务规则频繁变化,且类似的模式不断重复出现,并且容易 ...

  2. 【COSMOS】跨链协议IBC概述

    一.什么是IBC? IBC是链间通信协议的缩写(Inter-Blockchain Communication Protocol).通过数据包交换在多个不同的区块链网络之间转移数据和状态信息.最初的用途 ...

  3. localStorage的使用和vuex的拆分

    问题1:在隐身模式.或者用户未启用的情况下,使用localStorage可能会导致浏览器直接报错,怎么办? 方法:使用try-catch包裹 代码示例: store.jsimport Vue from ...

  4. document.getElementsByTagName()方法的返回值

    在阅读<JS DOM 编程一书>一书时,看到getElementByTagName函数返回值为数组,然后自己验证了下,发现不是数组,而是一个可遍历的HTMLCollection对象 HTM ...

  5. Hive内部表,外部表和分区表

    外部表和内部表的区别 内部表也称之为managed_table: 默认存储在/user/hive/warehouse下,也可以通过location指定: 删除表事,会删除表数据以及元数据: 外部表称之 ...

  6. DEV控件的分页控件,实现勾选复选框

    /// <summary> /// 单元格的点击事件 /// </summary> /// <param name="sender"></ ...

  7. 百度网盘SVIP不限速Mac破解版(亲测可用)

    百度网盘SVIP不限速Mac破解版(亲测可用),按照教程一步一步来就可以了,链接如下: https://mac.orsoon.com/Mac/166358.html?id=ODY0MDA2Jl8mMT ...

  8. netperf编译./configure时报错 "error: cannot guess build type;you nust specify one"

    问题: 解决办法-亲测可用: 尝试:./configure --build=mingw提示无法辨别 checking build system type... Invalid configuratio ...

  9. 牛客练习赛33 D tokitsukaze and Inverse Number (树状数组求逆序对,结论)

    链接:https://ac.nowcoder.com/acm/contest/308/D 来源:牛客网 tokitsukaze and Inverse Number 时间限制:C/C++ 1秒,其他语 ...

  10. DevExpress v19.1新版亮点——WinForms篇(三)

    行业领先的.NET界面控件DevExpress v19.1终于正式发布,本站将以连载的形式介绍各版本新增内容.在本系列文章中将为大家介绍DevExpress WinForms v19.1中新增的一些控 ...