目录

前言

这绝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. python之路之——操作系统的发展历史

    阅读目录 手工操作 —— 穿孔卡片 批处理 —— 磁带存储和批处理系统 多道程序系统 分时系统 实时系统 通用操作系统 操作系统的进一步发展 操作系统的作用 手工操作 —— 穿孔卡片 1946年第一台 ...

  2. OneDrive网盘资源下载教程

    目录 1. 本文地址 2. 下载流程 3. 打赏&支持 1. 本文地址 博客园:https://www.cnblogs.com/coco56/p/11161530.html CSDN:http ...

  3. 四、绑定SignaIR的用户管理

    一.用户分组(第一个默认我的好友,禁删和更改) 没有分组id,更改layim代码: 更改id即可. layui.define('jquery', function (exports) { " ...

  4. ztree点击加号+触发ajax请求

    之前做的时候一直是点击节点才触发ajax事件,配置如下:发现点击节点前面的“+”没有反应,后来发现,应该添加一个折叠的事件. onExpand:zTreeOnClick事件和onClick的一样. v ...

  5. zookeeper之三 ZKClient客户端的使用

    ZKClient在原生API接口上进行了包装,同时在内部实现了诸如session超时重连.watcher反复注册等功能,使得zookeeper客户端繁琐的细节对开发人员透明.下面将从以下几个方面来使用 ...

  6. Flutter-發送短信驗證碼

    import 'dart:async'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; ...

  7. Flutter SDK安装(windows)

    Flutter集成了Dart,因此不需要单独安装dart-sdk.Flutter的SDK可以从官网下载:https://flutter.io/sdk-archive/#windows 在Flutter ...

  8. bzoj1195 [HNOI2006]最短母串 AC 自动机+状压+bfs

    题目传送门 https://lydsy.com/JudgeOnline/problem.php?id=1195 题解 建立 AC 自动机,然后构建出 trie 图. 然后直接在 trie 图上走.但是 ...

  9. vue2.0发布

    http://blog.csdn.net/xuefeiliuyuxiu/article/details/78970815

  10. Python---进阶---Tkinter---game

    一.用tkinter写一个小游戏,来随机生成我们需要的名字 # 用tkinter写一个小游戏,来随机生成我们需要的名字 import tkinter as tkimport random window ...