0

I've installed today, the Screenfetcher module for Windows - as follows:

PS D:\INSTALKI\ScreenFetch>  Find-Module -Repository Local

Version    Name                                Repository           Description
-------    ----                                ----------           -----------
1.0.2      windows-screenfetch                 Local                Powershell port of the Bash Screenshot Information Tool
PS C:\> Get-Command -Module windows-screenfetch

CommandType     Name                                               Version    Source
-----------     ----                                               -------    ------
Function        Screenfetch                                        0.0        windows-screenfetch

Then I have created script: screenfetch.bat with such entry:

C:\>type "C:\Program Files\ScreenFetch\screenfetch.bat"
@echo off
echo.
PowerShell.exe -command screenfetch

Then I've added path: C:\Program Files\ScreenFetch to the windows variable PATH to run this script directly from a command line with command: screenfetch

But every time when I'm running command: screenfetch - then loop is starting and command is not executed.

But if I rename the script C:\Program Files\ScreenFetch\screenfetch.bat to any other name - example: C:\Program Files\ScreenFetch\dupa.bat - then script is executing properly:

C:\>"Program Files\ScreenFetch\dupa.bat"

                         ....::::       Marcin@Laptop
                 ....::::::::::::       OS: Microsoft Windows 10 Pro 64-bit
        ....:::: ::::::::::::::::       Kernel: 10.0.19044
....:::::::::::: ::::::::::::::::       Uptime: 0d 5h 50m 44s
:::::::::::::::: ::::::::::::::::       Motherboard: LENOVO 20FMS05K2D
:::::::::::::::: ::::::::::::::::       Shell: PowerShell 5.1.19041.1682
:::::::::::::::: ::::::::::::::::       Resolution: 1920 x 1080
:::::::::::::::: ::::::::::::::::       Window Manager: DWM
................ ................       Font: Segoe UI
:::::::::::::::: ::::::::::::::::       CPU: Intel(R) Core(TM) i5-6300U CPU @ 2.40GHz
:::::::::::::::: ::::::::::::::::       GPU Intel(R) HD Graphics 520
:::::::::::::::: ::::::::::::::::       RAM: 9278MB / 16205 MB (57%)
'''':::::::::::: ::::::::::::::::       Disk C: 130GB / 194GB (67%)
        '''':::: ::::::::::::::::       Disk D: 717GB / 753GB (95%)
                 ''''::::::::::::
                         ''''::::

Does anybody know why the loop is generating? What is wrong with the same PowerShell and CMD script name?

I would be grateful for any advice.

Rohit Gupta
  • 2,721
  • 18
  • 27
  • 35
Marcin
  • 1
  • Here you can find proper output screenshot: https://ibb.co/jMZHD76 – Marcin Dec 07 '22 at 15:22
  • 2
    Please don't use comments to add information. [Edit] your question instead. Copy&paste text to your question *as text* and format it as a code block instead of showing a screenshot. [Please do not upload images of code/data/errors.](//meta.stackoverflow.com/q/285551) – Bodo Dec 07 '22 at 15:42
  • What does `where screenfetch` show when your `screenfetch.bat` exists and when you have renamed it to `dupa.bat`? I'm not sure about PowerShell, but AFAIK Windows searches command extensions in the order of variable `PATHEXT`, so it might find your script `screenfetch.bat` before the real `screenfetch` command. – Bodo Dec 07 '22 at 15:55
  • 1
    I'm not a Windows guy and my knowledge may be fragmentary, therefore just a comment. [When a command is issued (…), the operating system will first look for an executable file in the current folder, if not found it will scan `%PATH%` to find it.](https://ss64.com/nt/path.html). When specify a command without extension, Windows tries few possibilities (traditionally `.exe`, `.bat`, `.com`). I guess the first working guess for `screenfetch` in your script is `screenfetch.bat` in the current directory, so the script, hence the loop. [Linux is different](https://superuser.com/q/156582/432690). :) – Kamil Maciorowski Dec 07 '22 at 17:50

0 Answers0