开机自启动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 ...
随机推荐
- 【源码解读】pix2pix(一):训练
源码地址:https://github.com/mrzhu-cool/pix2pix-pytorch 相比于朱俊彦的版本,这一版更加简单易读 训练的代码在train.py,开头依然是很多代码的共同三板 ...
- oracle数据的导入导出(两种方法三种方式)
大概了解数据库中数据的导入导出.在oracle中,导入导出数据的方法有两种,一种是使用cmd命令行的形式导入导出数据,另一种是使用PL/SQL工具导入导出数据. 1,使用cmd命令行导入导出数据 1. ...
- ECMAScript(ES) 6 之 let 与 const
ES6 新增加了两个重要的 JavaScript 关键字 :let 和 const 先说一下 const :它用于声明一个只读的常量,一旦声明,常量的值就不能改变. const servicePat ...
- java 技术分享
http://www.ccblog.cn/99.htm http://www.ccblog.cn/100.htm http://www.ccblog.cn/101.htm http://www.ccb ...
- 2--面试总结-深入理解js线程进阶-宏任务微任务
前言:Event Loop即时间循环,是指浏览器或Node的一种解决javascript单线程运行时不会阻塞的一种机制,也就是我们经常使用异步的原理 Js运行机制 1.不同运行环境,js运行 ...
- 控制DIV内容滚动的方法,实现不用拖滚动条就可以看到最新消息
三种控制DIV内容滚动的方法: 本人qq群也有许多的技术文档,希望可以为你提供一些帮助(非技术的勿加). QQ群: 281442983 (点击链接加入群:http://jq.qq.com/?_wv ...
- 常用windbg命令(转)
1.查看版本信息:version.vertarget. 2.查看模块信息:lm.!dlls.!lmvi等. 3.调用栈:用k命令显示调用栈,用.frames命令切换栈帧. 4.内存操作:读内存用d命令 ...
- FAT12
FAT12 is one of FAT file system families,mostly used on 1.44MB floppy disk. FAT 's full name is File ...
- mysql查看内存使用情况
SELECT table_name '表名称',table_rows '数据量(万)',data_size '磁盘(G)'FROM (SELECT table_name table_name, tru ...
- CTF Jarvisoj Web(session.upload_progress.name php 上传进度)
Jarvisoj Web 题目地址:http://web.jarvisoj.com:32784/index.php <?php //A webshell is wait for you ini_ ...