Categories
Operating Systems Windows 10

Quick and dirty robocopy script to back up directory

I used to have an xcopy script that ran this, but now I have upgraded to using robocopy to mirror my files to a network share that I disconnect and put in cold storage when not actually backing up.

robocopy E:\ \\192.168.50.30\backup\ /E /XD “System Volume Information” “$RECYCLE.BIN” “found.00*” /MIR

Break down of the script: E: is the SOURCE of my files and \\192.168.50.30\backup\ is my DESTINATION to copy TO. If you not the XD trigger, that EXCLUDES certain files. I want to ignore certain system files that do not matter to my back ups. You can do this for nearly any directory. /MIR is what actually MIRRORS the files, so they will look exactly like what you have on your SOURCE directory structure.

The only downside is there is no versioning with this, what you see is what you get, so if you were struck with some randomsware, this won’t save you. You would want something like seafile, or some other back up service. If there’s any interest, I can make a post on how to create a seafile server to do your back ups and version control. It has the added benefit of having versioning, browser accessible, and phone applications.

Categories
Computer Hardware Windows 10

microsoft surface pro 6 battery bar stuck at 100%

You would think this is a good thing, but no, haha. It’s nice to know what your battery is actually at. While the tablet was logged in, I did this key combo, and that resolved it:

hold volume + and power button for 15 seconds and that should fix it.

Categories
Operating Systems Windows 10 Windows 7 Windows 8

Ever want to bring up windows explorer from command prompt?

It’s super simple actually, just type “start .” without quotes. That will bring up the current directory in windows explorer. If you want to bring up another directory outside of the one you are in, just type “start C:\users\” as an example. If you want a network share: “start \\10.10.10.33\share\” and hit enter.

Easy 🙂

Categories
Operating Systems Windows 10 Windows 7 Windows 8

need to have your windows 10, windows 8, or windows 7 PC auto log you in?

Simple! Go to start, and run. Type in netplwiz and hit OK. Click on “Users must enter a user name and password to use this computer”, it will prompt for your password, and click ok, and you are done. It shoudl auto log you in!

Categories
INTEL NUC Kodi Windows 10

Windows 10 1607 anniversary update broke my RC6 remote KODI/XBMC

My RC6 remote up and broke on my when I updated Windows 10 to update 1607 ‘anniversary’ edition in Windows 10 on my Intel NUC. Long story short, I found out what it was, huzzah!

This was the remote I used: [easyazon_link identifier=”B01H1XUTYK” locale=”US” tag=”vivithemage-20″]Rosewill Accessory RHRC-11002[/easyazon_link] coupled with this older [easyazon_link identifier=”B00HVKLSVC” locale=”US” tag=”vivithemage-20″]Intel NUC DN2820FYKH [/easyazon_link]

So I had some free time to dig around on this on my own. Oddly enough, I had a back up from 2015 of this system, so I went to check my registry, and found out that this bit of the hive is volatile (only stored in memory), so I looked at the older ones in that save under currentcontrolset001/002 and found one difference. On my running system I went to:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\HidIr\Remotes\745a17a0-74d3-11d0-b6fe-00a0c90f57da\

and changed:

“CodeSetNum0″=dword:00000008

to:

“CodeSetNum0″=dword:00000001

GOOD TO GO, works fine now.

Oy. I don’t even remember what told me to change it to 8 in the first place.

Categories
Windows 10 Windows 8

Windows 10 or 8 System Interrupts causing high CPU usage

I had a few laptops where the system interrupt process was consuming 10-15% CPU. The one thing that seemed to have worked was disabling ‘turn on fast startup’ in the power settings.

Hit your start button and type power options and click on the power options.
Left side, ‘chose what the power buttons do’ click on that.
At the top of this page, click ‘Change settings that are currently unavailable’
Scroll to teh bottom, and uncheck ‘Turn on fast startup (recommended) and click save.
You can reboot, but this should solve the problem.

IF not, you might have a bad driver and need to try disabling hardware until you see the issue go away, and then work on updating that driver.

power

UPDATE:

I also found that disabling hibernation will remove this option completely. You can do this via CMD or POWERSHELL:

POWERSHELL:
powershell -Command "Start-Process 'powercfg.exe' -Verb runAs -ArgumentList '/h off'"

COMMAND PROMPT:
powercfg -h off

Categories
Powershell Windows 10 Windows 7

Running batch and powershell scripts as administrator

WINDOWS – RUN BATCH AND PS AS ADMINISTRATORS. This works for Windows 7 and newer. I tested on Windows 7 and 10 64bit and 32bit.

This is a faster vbs version of the below script:
net sess>NUL 2>&1||(echo.CreateObject^(“Shell.Application”^).ShellExecute”%~0″,,,”RunAs”,1 >”%TEMP%\%~nx0.vbs”&WScript “%TEMP%\%~nx0.vbs”&del “%TEMP%\%~nx0.vbs”&exit)

#RUNNING CMD/BAT files as administrator, place this at the top of script after @echo off
net sess>NUL 2>&1||(powershell saps ‘%0’-Verb RunAs&exit)

#RUNNING PS1 FILES as administrator, place this at the top, before all other commands.
# Run this if you need to be running as ADMINISTARTOR
If (-NOT ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] “Administrator”))
{
$arguments = “& ‘” + $myinvocation.mycommand.definition + “‘”
Start-Process powershell -Verb runAs -ArgumentList $arguments
Break
}
####################################################

SOURCE: http://www.sevenforums.com/general-discussion/12936-how-run-batch-file-admin-3.html#post3084570

Categories
powershell Programming scripting Windows 10 Windows 7 Windows 8

creating batch file to kick off powershell script in different versions of windows with different commands

I needed the ability to have a powershell script execute specific ways for specific versions of windows, so after some googling, I hodge podged this. Essentially you will run this script first, as a cmd, or batch file:

@echo off
setlocal
for /f "tokens=4-5 delims=. " %%i in ('ver') do set VERSION=%%i.%%j
REM Windows 10 is called be low this
if "%version%" == "10.0" powershell "C:\LocalAdminPolicyUpdate\LocalAdminPolicyUpdate.ps1"
REM Windows 8.1
if "%version%" == "6.3" powershell "C:\LocalAdminPolicyUpdate\LocalAdminPolicyUpdate.ps1"
REM Windows 8
if "%version%" == "6.2" powershell "C:\LocalAdminPolicyUpdate\LocalAdminPolicyUpdate.ps1"
REM Windows Vista
if "%version%" == "6.0" echo Windows Vista.
REM Windows 7
if "%version%" == "6.1" powershell "Set-ExecutionPolicy Unrestricted" && powershell C:\LocalAdminPolicyUpdate\LocalAdminPolicyUpdate.ps1
endlocal

and then this script, labeled LocalAdminPolicyUpdate.ps1 reload the script if it is not running as an admin. This section works for Windows 8+, and does not flag/error on Windows 7, which is why I needed the previous script to kick off ‘what version’ is the OS to run it elevated. I also am running these on PC’s WITHOUT UAC. If you have UAC, the user will get prompted to hit YES on the UAC popup.

The next bit finds all users in the local administrator group, and removes specific users with the $Group.Remove section, and then adds with the $Group.Add. I also added some debugging stuff to see what echo’d out to show me if it exists and it is truely seeing each user.

# Adds local uesr to local administrators account and removing software loaders
# revision 1
# created 2016-04-26

# Run this if you need to be running as ADMINISTARTOR
If (-NOT ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator"))
{
$arguments = "& '" + $myinvocation.mycommand.definition + "'"
Start-Process powershell -Verb runAs -ArgumentList $arguments
Break
}
####################################################

$members = net localgroup administrators | where {$_ -AND $_ -notmatch "command completed successfully"} | select -skip 4
#write-output $members

$Computer = $env:COMPUTERNAME
$GroupName = 'Administrators'
$User = $env:USERNAME

$ADSI = [ADSI]("WinNT://$Computer")
$Group = $ADSI.Children.Find($GroupName, 'group')

if ($members -notcontains "E500NT\$env:USERNAME") {
$Group.Add(("WinNT://e500nt/$user"))
}
if ($members -contains "E500NT\Software Loaders") {
$Group.Remove(("WinNT://e500nt/Software Loaders"))
}
if ($members -notcontains "E500NT\ISTechGroup") {
$Group.Add(("WinNT://e500nt/ISTechGroup"))
}
if ($members -notcontains "E500NT\Domain Admins") {
$Group.Add(("WinNT://e500nt/Domain Admins"))
}
#if ($members -contains "E500NT\$env:USERNAME") { echo 1}
#if ($members -contains "E500NT\ISTechGroup") { echo 2}
#if ($members -contains "E500NT\Domain Admins") { echo 3}
#if ($members -notcontains "E500NT\Software Loaders") { echo 4}

Categories
Windows 10

Disabling UAC in Windows 10 but keeping built in apps working like metro apps and edge

If you need to disable UAC, but want to keep the ability to use built in metro apps, like Edge, you can run this:

cmd /c REG ADD “HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System” /v ConsentPromptBehaviorAdmin /t REG_DWORD /d 00000000 /f
cmd /c REG ADD “HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System” /v PromptOnSecureDesktop /t REG_DWORD /d 00000000 /f

If you want some specifics on what other things you can modify to tweak the way UAC handles prompts you can view them here: https://msdn.microsoft.com/en-us/library/cc232762.aspx

There are a few more registry settings you can change, but with these two, in Windows 10, you will at least be able to keep metro apps running. If you want to disable UAC entirely in Windows 10 you can run this:

cmd /c REG ADD “HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System” /v EnableLUA /t REG_DWORD /d 00000000 /f

This will disable UAC, and kill all metro app usage.

Categories
Windows 10

Create batch file to run with elevated permissions to activate windows 10

I had a task of automating Windows 10 upgrades from Windows 7, and one key thing I needed to do was allow for UAC to exist, AND be able to run batch scripts, or powershell scripts as Administrator. Also known as elevated permissions.

I created a bat file with these contents:

set mydir=%~dp0
Powershell -Command “& { Start-Process \”%mydir%2.bat\” -verb RunAs}”

I then created a second bat file with 2.bat, and placed it in the same directory with this:

cscript C:\Windows\System32\slmgr.vbs -ipk xxxx-xxxx-xxxx-xxxx-xxxx
cscript C:\Windows\System32\slmgr.vbs /ato

This only brings up ONE prompt for the user, the UAC prompt to hit yes. No password required, and not VBS pop ups showing status, thanks to cscript.