Turn Bluetooth On/Off Windows 8.1 from Command Line Prompt - command-line

Currently Windows 8.1 has users jumping through hoops to reach the settings that manage bluetooth connectivity (Charms->Settings->Change PC Settings->PC and Devices->Bluetooth->On/Off). I was wondering, is there any way to programmatically turn the bluetooth on/off from the command prompt? I just want to write code that basically does what the Windows OS appears to be doing from that settings screen, to simply switch the bluetooth on/off.
I don't want to simply make a shortcut link to the settings as some folks suggest. I'm challenging myself to write a script or program that can do this, but these past few days I've googled the net for information and at this point I'm not sure if it can even be done. I've even tried installing a Windows bluetooth command line library called "Bluetooth Command Line Tools" and tried using their "btconfig -c0" command, but it doesn't seem to work. Is there a language/approach/methodology that I can employ towards achieving this goal? Thanks!

From this answer from Microsoft Community, I think there is no way to do that.
There is no Microsoft software to access Bluetooth from command prompt.
How to enable Bluetooth and pair with a device using command line?
Look at this thread for Win10

Something like this should do the job:
for /F "tokens=3 delims=: " %%H in ('sc query "bthserv" ^| findstr "STATE"') do (
if /I "%%H" NEQ "RUNNING" (
net start "bthserv"
) else if /I "%%H" NEQ "STOPPED" (
net stop "bthserv"
)
)
This will check if Bluetooth service is running and if it is, it will stop it.
If it is not, it will start the service.

Related

How do I check for a running process before executing another?

I've found some references to searching for active .exe in the task list but I haven't been able to get any to work.
I'm trying to find a working bat script because I have memory problems and I've been banned twice now for simply forgetting to shut it down.
I have tried the other suggestions on here but they are from 2012 and didn't seem to be working.
I am running Win 10 Home. Any help would be appreciated.
I am not a proficient coder. I can read it and determine what it's supposed to do, but I don't know how to fix it if it doesn't.
For the non-coders looking at this from a google search, this is attempting to create a batch file that simply checks if Cheat engine is running. If it is it pauses and tells me and stops the launcher from loading until Cheat engine isn't in the process tree.
The first bit I found on Reddit by someone who searched through your site to come up with this. It is about 2 years old but doesn't appear to work anymore, as far as I can tell.
tasklist /FI "IMAGENAME eq Cheat engine.exe" 2>NUL | find /N "Cheat engine.exe">NUL
if "%ERRORLEVEL%"=="0" start "" cmd /c "echo [Cheat engine running.]&echo(&pause"
if "%ERRORLEVEL%"=="1" start "" F:\SteamLibrary\steamapps\common\Warframe\Tools\Launcher.exe
That's what I've found. But it never returns an error, even when I run it while intentionally running CE. I never go past the launcher so it shouldn't flag in their system, therefore I should be able to test this as much as necessary.
and
just to see if I could run a kill process for it. This didn't do anything.
echo off
tasklist /fi "imagename eq cheat engine.exe" |find ":" > nul
if errorlevel 1 taskkill /f /im "cheat engine.exe"
exit

Dell BiOS update

I am working as a helpdesk on my company. New to command lines and PowerShell. I've a company that manages around 100 laptops which I manually upgrade their BIOS. During manual upgrade, it automatically suspends the BitLocker. I've found a silent way to do this on PowerShell through Dell Documentation using this command:
Below is an example output from the Latitude E6520 BIOS executable “E6520A05.exe”.
General usage:
Typical Syntax: Filename.exe [/<option1>[=<value1>]] [/<option2>[=<value2>]]
Option - Description:
(none) - Display of graphical user interface for guided update.
/? or /h - Displays this Dell System BIOS Update usage information.
/s - Suppresses all graphical user interfaces of the BIOS System BIOS Update.
/l= - Define a specific path for the Dell System BIOS Update log file.
/f - Override a soft dependency error returned from the Dell System BIOS Update. NOTE: Requires /s option.
/r - Reboot the system to complete the update. NOTE: Requires /s option.
/p= - Provide the BIOS password (if needed) to perform the BIOS update.
Example(s):
Update the system silently: Filename.exe /s
Change from the default log location (example target path: C:\my path with spaces\log.txt)
Filename.exe /l=”C:\my path with spaces\log.txt”
Force update to continue (even on “soft” qualification errors): Filename.exe /s /f"
In my case my laptops are DELL Precision 5530, and updated using this command
.\Precision_5530_1.25.0.exe /noPause /s /f /l=C:\Temp\BiOS.log
My question is our company policy has BitLocker on, and system admin suggested the above command will work fine but find a way to suspend BitLocker before doing that (so we can avoid crashing the laptop that's out of warranty) but also make sure to turn on after the update. I've searched everywhere but could not find relevant information.
Any insight on this would be helpful.
Thank you.
In powershell:
Suspend-BitLocker -MountPoint "C:" -RebootCount 0
Or in a batch file:
manage-bde -protectors -disable c:

Deny windows pop-up error messages with batch or powershell

I am working on a way to start a program via a network drive.(Example follows). Is there a way to suppress these error messages from Windows via Batch or Powershell while the script is running? Or maybe a way to dynamically search for the Network drive without trying all possible ways.
Code Exapmple:
#echo off
start A:"Path to .exe" 2>nul
B...
C...
// For every possible drive letter
you can easily get all successfully connected network drives with the net use command. Put a for /f loop around to get the drive letters only:
for /f "tokens=2" %%a in ('net use^|findstr /b "OK"') do (
start "" "%%a\path to .exe\app.exe"
)

Powershell script to capture dump using DebugDiag?

I am working on a script that can capture dump using debug diag for an IIS appPOOL.
i can work on a .VB script however business demands powershell script in this case.
I am unable to find any related post on internet.
As of now i dont even know, if we have a powershell module for debug diag.
Can someone point me in the right direction ?
There is no native way to capture IIS App pool dumps. But you can convert this batch script to PS:
%windir%\system32\inetsrv\appcmd list wps /apppool.name:"Microsoft Team Foundation Server Application Pool" /text:WP.NAME > "%temp%\tfspid.txt"
:: ProcDump.exe (faster, reflects/clones the process for the dump to minimize the time the process is suspended (Windows 7 and higher only))
for /F %%a in (%temp%\tfspid.txt) do "%~dp0\procdump.exe" -accepteula -64 -ma -r %%a f:\dumps
pause
Reference Link: APP Pool Dump

Restarting PC's and writing to the event log with a custom message

I have written a script in PowerShell that will remotely restart a list of PC's using the 'Restart-Computer' command.
Is there a way of adding a custom message to the systems event log, to explain that the computer has been restart by my script.
Here is the PowerShell code that I used to solve this problem as suggested by the user C.B. above.
Shutdown /r /f /m ComputerName /d P:0:1 /c "Your comment"
This code will force (/f) a shut down and reboot (/r) of a given PC and write to the event log with a custom comment (/c). Note that to write a custom comment a reason code will need to be supplied using the (/d) parameter. Also note that the order of parameters matters.
For a list of reason codes and syntax follow the links below.
http://ss64.com/nt/shutdown.html
http://technet.microsoft.com/en-us/library/cc732503(v=ws.10).aspx