tthh
tthh

Reputation: 31

How does one import module inside the cmd?

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.

Upvotes: 0

Views: 1661

Answers (1)

lit
lit

Reputation: 16266

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 ...

Upvotes: 2

Related Questions