New answers tagged

-1 votes
Accepted

I need to restart my PC if theres no network connection after about 1 minute

The following code should restart your computer if the interface set in variable $interfaceName is on state "Disconnected" $interfaceName = "Ethernet" $interfaceState = (Get-...
user avatar
0 votes

Displaying users and their home directory but NOT WITH awk

This site is not for solving your homework. However, I'll give you some hints: man cut. look at the -d and -f options sed can be used to remove the unwanted fields from a line. Such a field could ...
user avatar
  • 1,871
0 votes
Accepted

Custom Scheduled Tasks in Win11 causing PowerShell & CMD.exe pop-ups - how to make them silent / background tasks?

To avoid seeing the PowerShell command window pop-up from a Scheduled Task: Change your Scheduled Task account to run in the SYSTEM context, then either hard-code your $yourUser variable to a known ...
user avatar
0 votes

How to check Internet browsing history through cmd or powershell on Windows?

I like the Ipconfig use, but Powershell does have its own code Get-DnsClientCache | Select-Object -Property Entry, Data | Sort-Object Entry | FT
user avatar
1 vote
Accepted

[[ -v var ]] behaves differently inside bash script vs CLI

Apparently var is set in your interactive shell (it's not in the environment though). Then [[ -v var ]] returns success and echo "\${var} not defined" is executed. You see not defined ...
user avatar
0 votes

How to test PXE from the commandline?

To answer my own question - I have spent some time trying things out and realised what I needed was a way to see what the DHCP server replies, when PXE starts up. PXE relies on two services: DHCP for ...
user avatar
  • 317
1 vote
Accepted

How do i return true/false on get-content command for each username inside C:/Users?

I've managed to work out that i was missing Get-Childitem in the equation. This is the correct way to do it, although I'm sure my PS is in need of major improvement, as I was unable to get a properly ...
user avatar
  • 751
0 votes

Terminal commands to color differences between two files

As mentioned in the comment, diff can do this for you diff out.txt expected.txt —-color
user avatar
  • 60.8k
0 votes

how to create batch code to filter the content of all txt file and add a sentence based on filtered text

Remark : This is just for testing with only one file with drag and drop. If we had for example the input file like this one : Hello Other Stuff here A123 Line 3.... Line 4..... Line 5...... Line 6.......
user avatar
  • 1,120
0 votes

Converting a PDF to black & white with ghostscript

ImageMagick can do it. convert -posterize 2 input.pdf output.pdf Comes out nice & crisp, and about a 3rd the file size of the color original.
user avatar
  • 1
-1 votes

How can I open WSL terminal with a command without it automatically closing?

C:\Windows\System32\cmd.exe /k wsl /path/to/script.sh /k switch makes cmd not exit so you can read the output. wsl does not have a similar switch.
user avatar
0 votes

How to test PXE from the commandline?

For testing, a web-server can be used as a "PXE boot server", doing the PXE boot without TFTP and by re-using the DHCP server that is already built into libvirt. Libvirt uses iPXE as the ...
user avatar
  • 407k
1 vote

Can someone please explain how to loop the backup logic ( below mentioned script )

To run it multiple times at set times you should use cron or your distros equivalent. As for doing incremental with tar files you need to use --listed-incremental It's a bit more involved so I'll link ...
user avatar
0 votes
Accepted

How to remove files that don't show up in CMD dir list but do show up in power query

Files that start with ~$ are often temporary files. Because they are irrelevant for users to see, they are often created with the hidden attribute set, and as such, you don't see them if you type dir. ...
user avatar
  • 55.1k
0 votes

How can I kill all headless Chrome instances from the command line on Windows?

in case someone gets here by google search... On OSX this also works: sudo killall Google\ Chrome
user avatar
1 vote
Accepted

How to successfully Install Azure CLI

On windows, you can find the Azure CLI az.cmd here: C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\wbin And this path can be found in the Environment variable Path: PowerShell: $Env:Path C:\...
user avatar
0 votes

How to crop an image using ImageMagick from the command line?

Crop centered in batches for f in *.jpg; do convert "$f" -gravity center -crop 98x98+0+0 +repage "$f" ; done Fulfil with -extent in a canvas -background white for f in *.jpg; do ...
user avatar
  • 101
0 votes

Elevated command line prompt can't access shared drives

A far from ideal solution, is mklink, as it's not creating a new drive, but it is creating a directory on your local drive, that links to a network drive. mklink doesn't have the problem that you are ...
user avatar
  • 21.9k
0 votes

Works from terminal prompt. How to get bash script working?

Adding to Kamil's answer ... #!/bin/sh script /home/x/Desktop/clamlog2.cat -c ' clear # reduce scroll-back text / screens. bash /media/x/usb_stick/clamscan.sh ...
user avatar
0 votes

Works from terminal prompt. How to get bash script working?

Explanation Lines in a shell script do not simulate keyboard input. Each statement is a command that must finish before the next is run, and the entire thing runs in the context of the parent shell. ...
user avatar
1 vote

Is there any way to trick a program to writing to stdout when it expects a file?

Did you try to use the special con file as output? Something like: UV4.exe -r Blinky.uvproj -o con
user avatar
0 votes

How to do recursive file search of hidden files on Windows?

Finally the answer was : CMD : dir /a:H /s POWERSHELL : ls -ah -recurse (option -force)
user avatar
0 votes

How to turn on/off Airplane Mode(Windows 10) thro' Batch file or Command Prompt?

This may be the simplest method although it requires admin. :wifioff net stop WlanSvc & goto :eof :wifion net start WlanSvc & goto :eof alternately reboot and the service is automatically ...
user avatar
1 vote

Installing Windows 11, new laptop, can't see hard drive in installtion

You need to manually load your Rapid Storage Driver or Serial ATA Driver for your hard drive to appear. Step 1 - Download the driver specific to your Dell model laptop onto a USB https://www.dell.com/...
user avatar
  • 751
0 votes

Running a batch script from a network drive

Add this to the top of your batch script to have it automatically run as admin @ECHO OFF REM --------------------------Start of getting superuser permissions-------------------------------------------...
user avatar
  • 751
0 votes
Accepted

Windows 10 editing internet options via command line

On my computer, proxy exceptions are stored in a value named "ProxyOverride" in the same directory. You can get it with this command : reg query "HKEY_CURRENT_USER\Software\Microsoft\...
user avatar
0 votes

How can I find out which folder http://localhost:3000 points to?

Thanks to Daniel B's comment, I managed to figure out that a cached version of the page was running under that port via a service worker. To fix, I went to the Application tab in Chrome DevTools and ...
user avatar
  • 199
1 vote

Automatically answer command input from .py script

Try: echo 3 | python Algo_demo.py or echo %var% | python Algo_demo.py where %var% is a variable you previously defined....
user avatar
0 votes

Export to PDF with LibreOffice command-line, selecting an output filename

Just rename it after it saves. it will be the exact name with .pdf on the end.
user avatar
2 votes
Accepted

Running desired number of executables on Windows using batch script

@echo off & setlocal for /d /r %%i in (*)do if exist "%%~i\run_jobs.bat" call %:^) "%%~dpnxi" "run_jobs.bat" endlocal && goto :eof %:^) if not "%~1&...
user avatar
  • 6,323
-1 votes

How to convert .reg files to PowerShell set-itemproperty commands automatically?

This is pretty good, but you have some errors in your conversion code. In reg value text that contains escape characters like "cmd.exe /s /k pushd "%V"" your conversion doesn't ...
user avatar
0 votes

script to run sox to combine multiple mono tracks to stereo

a python solution using sox called via os.system() I have a tascam model 12 that I use to record, and when I import the folders, I want to combine the main mix into a stereo track. Doing this in a ...
user avatar
0 votes

Update Powershell through command line

Cheat Sheet - Upgrade to PS 5.1 Easy as 123 - Estimated time to complete - 30 minutes 1.) Install, Verify .NET Framework is 4.5.2 or newer if not Download - Install Version 4.8 here: https://go....
user avatar
0 votes

Command line document scanner

I wrote a Python based CLI for scanning documents on Mac. You can find it here: https://github.com/zegman/scanner-cli It provides a CLI interface which can be used to start a scan and capture it to a ...
user avatar
1 vote

What's the easiest way to map "ls" to the "dir" command in Windows?

In PowerShell both dir and ls have the same effect, one is an alias of the other.
user avatar
  • 407k
1 vote

What's the easiest way to map "ls" to the "dir" command in Windows?

In PowerShell, such an alias is already present by default. (More precisely, both ls and dir are aliases to the Get-ChildItem cmdlet. It also has default aliases for cat, rm, etc.) So just use DOSKEY ...
user avatar
  • 376k
0 votes

How to open windows 10 in cli/tui mode

Commentors have said this, but I'm making this an answer, and the answer is no, Windows desktop OSes cannot boot to command-line only mode in any way. There are not work arounds. There are not tricks....
user avatar
  • 38.9k
0 votes

Why aren't there more native command line shells for Windows?

There are, maybe haven't gotten enough publicity? There is another Bash shell for Windows, from a direct W32 port. No, not WSL, not VMs, no not Cygwin. It even handles drive letters. I used this a ...
user avatar
  • 1,169
0 votes

Terminal returning error "bash: /usr/bin/(command) /bin/bash: bad interpreter: No such file or directory" unless command is preceded with bash

Solved. It was simply a broken symlink in regards to bin. Thank you davidgo for pointing me in the right direction, it was not bash but rather the bin I guess. A different user had also commented ...
user avatar
0 votes

How do I use command line to make an mp3 file an Mp4 file with visualisations? Is it possible to batch convert a folder with MP3's into videos?

/sdcard/ghostbox $ ls bank output000.mp3 gbox output001.mp3 image.jpg output002.mp3 mp3tomp4.sh recvol How to run THE command om next Line 4 all *.mp3 files. echo &...
user avatar
  • 1
0 votes

ffmpeg adding subtitles with options

Should be: "subtitles=\'<srt_path>\':force_style='FontName=Z003,PrimaryColour=&HCCFF0000&'" Note the double quote around the whole subtitles part, and the trailing ampersand ...
user avatar
0 votes

How do I tell Homebrew to stop running brew update every time I want to install something?

I recommend installing homebrew-autoupdate. Run: brew tap homebrew/autoupdate This is a script that will automatically run brew update in the background once every 24 hours, or on system boot. Then ...
user avatar
0 votes

How to identify USB webcam by serial number from the Linux command line

You may also be able to look at them under /dev/v4l/by-id which includes the short serial. ls -l /dev/v4l/by-id/ | sort
user avatar
1 vote

delete all subfolders using a batch file?

Use PowerShell, as it is much more powerful than cmd. You need to install PowerShell 7, then you may also want to install Windows Terminal, if you don't know how to install and open them, there are ...
user avatar
1 vote
Accepted

Windows 10 Desktop shortcut not starting new session

Use the following as the command of the shortcut : cmd.exe /c start "" cmd.exe /k D:\WorkDir\Scripts\launchDevEnv.bat This will start a new CMD session, while the cmd.exe /c session ...
user avatar
  • 407k
0 votes

How to print to PDF from a windows command line?

In order for a PDF to not be editable, it must be secured with encryption using a PDF editor; even then, if the PDF is Printed to PDF, the encryption and/or its digital signature does not go with it (...
user avatar
  • 5,934
1 vote
Accepted

Remove sub-directories from multiple parent folders

This is an adapted/ported version of your question which is based on a very similar question here and in this answer you have an explanation about the "mechanics" applied in getting the last ...
user avatar
  • 6,323
1 vote
Accepted

delete all subfolders using a batch file?

You can try: @echo off cd/d "%~dp0" for /f delims^= %%i in ( 'dir /a:d/s/b ^| findstr /eil "\bin \obj"' )do echo; rd "%%~i" Obs.: 1 Its syntax tends to serve ...
user avatar
  • 6,323
1 vote
Accepted

For loop not working, when preceded by "cd /d" (Windows 10, batch file)

Your script assumes that %CD% will preserve its original value from beginning to end. But that's not how this variable works – it is dynamically updated by the interpreter to always represent the ...
user avatar
  • 376k
1 vote

How to parse each line of a text file as an argument to command prompt in Windows?

With Powershell : foreach($line in GC PathFolder\File.txt) {Write-Host command_name argument --option $Line} With Command line : Using FOR /f For /f "delims=" %a in ('Type "File.txt&...
user avatar
  • 1,120

Top 50 recent answers are included