Is there a way detect size of taskbar buttons (small or large) on Windows 7,10?
There is a registry that could be used HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\TaskbarSmallIcons but I don't know if electron provides ability read registry
You can do this with 2 methods, they all would query the registry key on your application load, and you could send the data either via IPC from your main to the render process or as preload script in the render process only.
Spawn a process that executes reg query or similiar and you then parse the result string. I personally would do it via Get-ItemProperty in powershell. (simple)
This should return you the value as a JSON
Get-ItemProperty -Path Registry::HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name TaskbarSmallIcons | Select-Object -Property TaskbarSmallIcons | ConvertTo-Json
Create/Use a native node module to call the Windows API (harder)
Related
I wrote a script to send a notification in Windows 10 but it failed SILENTLY. Then I realised that the Notifications was turned off. But I can't seem to find if there is a command to check if Notification is turned on or off.
How do I programmatically check if the Notification is On or Off?
There is no direct way to check this using PowerShell,
But may be you can check registry value and get that value returned and go for if-else condition to fulfill your code.
Usually the value of ToastEnabled DWORD located at
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\PushNotifications says the status of PushNotifications
If ToastEnabled DWORD,
0 = PushNotifications Turn off
1 = PushNotifications Turn on
Below code will help you to read , whether that value is 1 or 0.
$key = 'HKCU:\Software\Microsoft\Windows\CurrentVersion\PushNotifications'
(Get-ItemProperty -Path $key -Name ToastEnabled).ToastEnabled
Also, if you wish you can check whether "Action Center in Windows" has been disabled
$key2 = 'HKCU:\Software\Policies\Microsoft\Windows\Explorer'
(Get-ItemProperty -Path $key -Name DisableNotificationCenter).DisableNotificationCenter
Note DisableNotificationCenter is not a default key just like ToastEnabled. Someone has to manually create it. So if that has not been created, you will not see 0. Instead you may get
Get-ItemProperty : Property DisableNotificationCenter does not exist at path
I'm hoping to find a solution that doesn't require a large block of text / code, hopefully only 1 or 2 lines in a .bat script.
So far the main PowerShell call that does these 2 things is the Get-PhysicalDisk, MediaType and Size,
But Size doesn't automatically abbreviate to GB / TB, but I know it or Format Table can, because it does abbreviate to GB / TB if the column it is listed in is restricted in size (width), but I can't figure out a way to force it to?
The standard entry I've used from command prompt is:
PowerShell "Get-PhysicalDisk | FT -AutoSize"
Which gives me something like:
Output on Command-Line
Which looks perfectly fine so long as your HDD / SDDs don't have some insanely long Serial #. In which case you don't even get to see the size. But the real issue is if you want to customize this so you always see the Size ie: PowerShell "Get-PhysicalDisk | FT Size, MediaType, FriendlyName, HealthStatus, OperationalStatus -hideTableHeaders -auto"
Now the size doesn't get summarized in GB, it gets the full number treatment like so:
Output on Command-Line
So is there a way to format or adjust this simply so it'll list in GB, while also having a listed Media Type? (forgot to add that in the end reminder) and if it has to be with a script does anyone have a succinct one?
~TY in advance!
An additional Q, using PowerShell "Get-Disk | FT -auto"
I get a good abbrev in GB as well, but can't |FT the "Total Size" since it has a space in it? or is there a trick to that?
Output on Command-Line
Apply Using PowerShell's Calculated Properties article e.g. as follows:
Get-PhysicalDisk |
Format-Table -Property #{Name='Size GB'; Expression={$_.Size / 1GB}},
MediaType, FriendlyName, HealthStatus, OperationalStatus -AutoSize
I have a windows 10 system on which there are 2 NIC's, both connected to different networks and both of them are assigned static IPs (Eg: IP_1=170.30.120.1 and IP_2=10.20.20.1).
When the Network_2 is down momentarily only IP_1 is listed in the commandline when Ipconfig commands were used. Is there a way for me to retrieve both the static IPs even if the network is momentarily down?
I have tried ipconfig , powershell commands and few more. Since the static IPs are assigned to both, can I get both IPs irrespective of their network state?
You can try PowerShell script to get the NetworkAdapterConfiguration object and Filter based on DHCPEnabled to be false.
Get-WmiObject -Class Win32_NetworkAdapterConfiguration -Filter DHCPEnabled=False -ComputerName . |Format-Table
This formats the output in a table format. However, you can play around with the command a bit more to get the desired output format and information by changing Filter etc.
I am using powershell to sift through my event log in event viewer. The challenge is to locate specific character sets inside the message detail and to display both the events with those character sets and the individual character sets themselves.
Right now, I have the following:
Get-WinEvent -FilterHashTable #{LogName="Application"; id=1035} -MaxEvents 10 | where {$_.message -like "* Visual C++ *" }
This script will return the events that have messages with Visual C++ inside, however there is a set of about 7 characters after that ranging in letter and number. I need to extract those 7 characters and print them exclusively. Thank you for all help.
When using MATLAB through the GUI, I can interrupt a computation by pressing Ctrl-C.
Is there a way to do the same programmatically when using MATLAB through the MATLAB Engine C API?
On Unix systems there is a solution: send a SIGINT signal. This will not kill MATLAB. It'll only interrupt the computation. I am looking for a solution that works on Windows.
Clarifications (seeing that the only answerer misunderstood):
I am looking for a way to interrupt any MATLAB calculation, without having control over the MATLAB code that is being run. I'm looking for the programmatic equivalent of pressing Ctrl-C in at the MATLAB command window, on Windows systems. This is for a Mathematica-MATLAB interface: I need to forward interrupts from Mathematica to MATLAB. As mentioned above, I already have a working implementation on Unix; this question is about how to do it on Windows.
One way would be to make the MATLAB Engine session visible, prior to executing long computations. That way if you want to interrupt execution, you just bring the visible command window into focus and hit Ctrl-C.
This can be done using the engSetVisible function
Here is a quick example I tried using MATLAB COM Automation. The process should be similar since MATLAB Engine is implemented using COM on Windows (pipes are used on Unix instead).
The scripting is done in Powershell:
# create MATLAB automation server
$m = New-Object -ComObject matlab.application
$m | Get-Member
# make the command window visible
$m.Visible = $true
# execute some long computation: pause(10)
$m.Feval('disp', 0,[ref]$null, 'Press Ctrl-C to interrupt...')
$m.Feval('pause', 0,[ref]$null, 10)
# close and cleanup
$m.Quit()
$m = $null
Remove-Variable m
During the pause, you can break it by hitting Ctrl+c in the command window:
There isn't a direct way: all of those routines have to be unwound and their workspaces
cleaned up, which might invoke exit handlers, and so on.
The closest I can think of is to have your main routine have a try/catch
and then when you wish to abort, error() the particular string that the
catch is keyed for, and when you detect it, bail out cleanly from your
main routine.