0
votes

Currently, I'm using this,

cd Images powershell.exe & Import-Module .\Resize-Image.psm1 & Resize-Image ....

What this does in PS, is that it will import the module and I'm able to use it's function to rescale my pictures and output it, it works pretty well in PS but i'm intending to use cmd prompt to call this as my other lines of codes are in cmd prompt. When i use this in cmd, it just displays

Windows PowerShell Copyright (C) Microsoft Corporation. All rights reserved.

and is waiting for a new command even though the above code is in a .bat file.

1
Powershell is way more advanced and easily able to replace any functionality created in cmd. That would be the perfect occasion to migrate your batch to a more modern and uptodate Powershell-Script. It would even avoid the need to switch between two different technologies. .... and btw. Powershell can run most of the cmd commands without any change. ;-) - Olaf
Hmm, Powershell is kinda unfamiliar for me but i'll give it a go and see where it takes me . Thanks! - tthh

1 Answers

2
votes

The code presented starts PowerShell, but has no command for it. After the AMPERSAND, the next command is Import-Module which is unknown to cmd.exe.

PowerShell commands can be separated by a SEMICOLON character.

cd Images
powershell.exe -NoLogo -NoProfile -Command ^
    "Import-Module .\Resize-Image.psm1; Resize-Image ...."

If you could run in PowerShell:

Set-Location './Images'  # probably should have a fully-qualified path
Import-Module './Resize-image.psm1'
Resize-Image ...