Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if (-Not (Test-Path "C:\Temp\tik.txt" -PathType leaf))
- {
- New-Item "C:\Temp\" -Name "tik.txt" -ItemType "file"
- $RunOnceKey = "HKLM:\Software\Microsoft\Windows\CurrentVersion\RunOnce"
- $ScriptPath = $MyInvocation.MyCommand.Definition
- $ScriptExecPath = "C:\Windows\System32\WindowsPowerShell\v1.0\Powershell.exe -File "
- $ScriptFullExecPath = $ScriptExecPath + $ScriptPath
- Set-ItemProperty $RunOnceKey "NextRun" $ScriptFullExecPath
- #Do first part of stuff here
- Restart-Computer
- }
- else
- {
- Remove-Item "C:\Temp\tik.txt"
Add Comment
Please, Sign In to add comment