目录

前言

这绝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. Paper Reading_Computer Architecture

    最近(以及预感接下来的一年)会读很多很多的paper......不如开个帖子记录一下读paper心得 Computer Architecture Last level cache (llc) perf ...

  2. STL容器概述

    STL容器 1.容器概述 1.1.容器分类 1.1.1.顺序容器:提供对元素序列的访问,顺序容器为元素连续分配内存或将元素组织为链表,元素的类型是容器成员value_type. 顺序容器 说明 vec ...

  3. wordpress中page页添加非插件留言板功能

    把下面的代码插入到page页面中即可 <!-- 留言板 --> <div class="wrap"> <div id="primary&qu ...

  4. k3 cloud付款单提示余额不足,科目余额表中余额为正,银行存款流水账中未负数

    对比科目余额表中的科目明细账和银行存款流水账,发现科目余额表不全,这说明有部分凭证没做,付款的时候验证的主要以银行流水账为主(主要来自现金流量表),这时候需要调整出纳部分和总账部分

  5. vue.js table组件封装

    table组件 和 分页组件来自iview,在这里我根据公司业务再次做了一次封装,使用slot进行内容分发,可以随意放置input输入框和button按钮 ,再使用props向子组件传递参数,使用em ...

  6. 40. Combination Sum II (JAVA)

    Given a collection of candidate numbers (candidates) and a target number (target), find all unique c ...

  7. Centos安装 Apache2.4提示 APR not found的解决办法

    在安装apache2.2.22版本的时候没有任何问题,可直接使用命令编译安装. 但是,在apache 2.4.12版本,./configure 进行配置时, 提示 configure: error: ...

  8. linux extglob模式 和rm反选,除了某个文件外的其他文件全部删除的命令

    1.extglob模式开启之后Shell可以另外识别出5个模式匹配操作符,能使文件匹配更加方便. 不然不识别 #开启命令: shopt -s extglob #关闭命令: shopt -u extgl ...

  9. 2014百度之星初赛第二场hdu 4831 Scenic Popularity

    Scenic Popularity Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others ...

  10. Tensorflow揭秘

    https://www.bilibili.com/video/av64970827/?p=7 tf2.0主要使用tf.keras api来构建模型,主要包括如下几个部分 一.Layers 如下是一些特 ...