How to invoke UAC in a Windows Batch script

Here is my quick and easy way to raise the privilage level of a Windows Batch script; allowing you to run your code at an administrator level. This is not a new question and has been asked many times on StackOverflow forums. The best answer I was able to find was the following from dbenham: https://stackoverflow.com/questions/1894967/how-to-request-administrator-access-inside-a-batch-file/10052222#10052222 That being said there are many ways to skin this cat, so I came up with my own method, all be it derivative. The main difference in the following code is that you will always get a UAC prompt in my variant of the code, even if you are currently running it as an account that is a member of the local administrators group: ...

December 29, 2020 · 2 min · Tom

Debian 9 - Running a python script at boot

There are a number of ways that you can run a python or bash script at system start but I am about to show you possibly the easiest way, using crontab. First you need to make that your script is executable and can run unattended. Then you need to login as the user your wish to execute the script as and edit the crontab file: crontab -e If this is your first time editing the crontab file, you might be asked which editor you wish to use – I chose nano. Once in the crontab file add a new line at the bottom of the file; it should look something like this ...

February 21, 2019 · 1 min · Tom

Modifying Windows shortcuts is Powershell

I once faced a rather tedious task that involved recursively modifying a number of shortcut paths stored across a convoluted folder structure. There was approximately 100 shortcuts which needed part of their path modifying. The answer: Create a****PowerShell script. The following code utilises regex to check for the existence of a string and modify with the define replacement. It is easily possible to use Read-Host to make this a little bit more interactive, but the purposes of my use-case it was just as simple to modify these variables before running the script. ...

February 13, 2019 · 2 min · Tom

Powershell - Checking the Language Mode

For security purposes, it is possible to control the language mode in a given Powershell session. These language modes can constrict which modules can be loaded during the life of a powershell session. Learn mode about Powershell langeuage modes: About Language Modes – Microsoft Detect the Current Language Mode $sLangMode: $ExecutionContext.SessionState.LanguageMode If ($sLangMode -ne “FullLanguage”){ Write-Host ” !! Unable to run scrit – Powershell Using Wrong Language Mode !! ” } Else{ ...

February 5, 2019 · 1 min · Tom

'Copy, Paste' With Powershell Sendkeys

This is really quick nugget of Powershell for anyone who is struggling to copy and paste into a particular window or dialog box. Perhaps it is a case of a website which prevents text form being sent to a field from the clipboard, or in my case, a windows UAC prompt. If you are following password best practices, your passwords should be long, complex and contain zero dictionary words. Furthermore, you should have a different password for every site and service. So, when a user interface doesn’t allow you to paste a password, life gets that little bit more difficult. ...

February 2, 2019 · 2 min · Tom