# Powershell with a predefined command?

**URL:** <https://resource.dopus.com/t/powershell-with-a-predefined-command/53761>\
**Category:** Off-Topic\
**Created:** [December 11, 2024, 3:36pm UTC](https://resource.dopus.com/t/powershell-with-a-predefined-command/53761 "2024-12-11T15:36:50Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![abr](https://resource.dopus.com/user_avatar/resource.dopus.com/abr/32/62448_2.png) [@abr](https://resource.dopus.com/u/abr)\
**Post date:** [December 11, 2024, 3:36pm UTC](https://resource.dopus.com/t/powershell-with-a-predefined-command/53761/1 "2024-12-11T15:36:50Z")

</div>

I have made a button

**@admin**  
**powershell**

but would like it to start using a predefined command, which would be

**`DISM /Online /Get-FeatureInfo /FeatureName:Recall`**

I tried just adding that command, but the window just closes. Maybe there is a trick? I am posting it here, because it's mainly about the Powershell syntax.

---

<div class="post-metadata">

**Author:** ![lxp](https://resource.dopus.com/user_avatar/resource.dopus.com/lxp/32/33734_2.png) [@lxp](https://resource.dopus.com/u/lxp)\
**Post date:** [December 11, 2024, 4:23pm UTC](https://resource.dopus.com/t/powershell-with-a-predefined-command/53761/2 "2024-12-11T16:23:23Z")

</div>

You probably just need to add a line with `pause` or `@leavedoswindowopen` to see the results.

BTW: `DISM` will run from a DOS prompt as well, no need for PS.

---

<div class="post-metadata">

**Author:** ![tbone](https://resource.dopus.com/user_avatar/resource.dopus.com/tbone/32/25726_2.png) [@tbone](https://resource.dopus.com/u/tbone)\
**Post date:** [December 11, 2024, 4:23pm UTC](https://resource.dopus.com/t/powershell-with-a-predefined-command/53761/3 "2024-12-11T16:23:44Z")

</div>

dism is not a powershell command..

---

<div class="post-metadata">

**Author:** ![abr](https://resource.dopus.com/user_avatar/resource.dopus.com/abr/32/62448_2.png) [@abr](https://resource.dopus.com/u/abr)\
**Post date:** [December 11, 2024, 4:31pm UTC](https://resource.dopus.com/t/powershell-with-a-predefined-command/53761/4 "2024-12-11T16:31:57Z")

</div>

Yeah, thanks, i will maybe try that. But i believe it would havo to run elevated.

Edit, none of that works. Looks like i need to keep pasting it from my clipboard.

---

<div class="post-metadata">

**Author:** ![abr](https://resource.dopus.com/user_avatar/resource.dopus.com/abr/32/62448_2.png) [@abr](https://resource.dopus.com/u/abr)\
**Post date:** [December 11, 2024, 4:33pm UTC](https://resource.dopus.com/t/powershell-with-a-predefined-command/53761/5 "2024-12-11T16:33:58Z")

</div>

But it works in Powershell. 🤔  
Maybe they included some of the old cmd shell commands?

---

<div class="post-metadata">

**Author:** ![lxp](https://resource.dopus.com/user_avatar/resource.dopus.com/lxp/32/33734_2.png) [@lxp](https://resource.dopus.com/u/lxp)\
**Post date:** [December 11, 2024, 4:40pm UTC](https://resource.dopus.com/t/powershell-with-a-predefined-command/53761/6 "2024-12-11T16:40:04Z")

</div>

It's not a DOS or PS command, it's a command-line utility (dism.exe).

---

<div class="post-metadata">

**Author:** ![abr](https://resource.dopus.com/user_avatar/resource.dopus.com/abr/32/62448_2.png) [@abr](https://resource.dopus.com/u/abr)\
**Post date:** [December 11, 2024, 4:48pm UTC](https://resource.dopus.com/t/powershell-with-a-predefined-command/53761/7 "2024-12-11T16:48:03Z")

</div>

It works anyway. See under 'check recall status'.

> **[GitHub - antonflor/RecallManager: A PowerShell tool to manage the Windows "Recall"...](https://github.com/antonflor/RecallManager)**
>
> A PowerShell tool to manage the Windows "Recall" feature using DISM commands. Easily check if Recall is enabled, and choose to disable or enable it with confirmation. Requires admin privileges and provides a simple way to control this feature. Run at your own risk.

Here's the result from that command

 ![grafik](https://resource.dopus.com/uploads/default/original/3X/0/7/07bde2207366851d2f955b758022e9b2714f809d.png)

---

<div class="post-metadata">

**Author:** ![Leo](https://resource.dopus.com/user_avatar/resource.dopus.com/leo/32/69732_2.png) [@Leo](https://resource.dopus.com/u/Leo)\
**Post date:** [December 11, 2024, 5:07pm UTC](https://resource.dopus.com/t/powershell-with-a-predefined-command/53761/8 "2024-12-11T17:07:00Z")

</div>

`PowerShell.exe /?` will tell you the arguments you can use to run PowerShell.

They include these, which should let you do what you need:

```plaintext
-NoExit
    Does not exit after running startup commands.

```

```plaintext
-Command
    Executes the specified commands (and any parameters) as though they were
    typed at the Windows PowerShell command prompt, and then exits, unless
    NoExit is specified. The value of Command can be "-", a string. or a
    script block.

    If the value of Command is "-", the command text is read from standard
    input.

    If the value of Command is a script block, the script block must be enclosed
    in braces ({}). You can specify a script block only when running PowerShell.exe
    in Windows PowerShell. The results of the script block are returned to the
    parent shell as deserialized XML objects, not live objects.

    If the value of Command is a string, Command must be the last parameter
    in the command , because any characters typed after the command are
    interpreted as the command arguments.

    To write a string that runs a Windows PowerShell command, use the format:
        "& {<command>}"
    where the quotation marks indicate a string and the invoke operator (&)
    causes the command to be executed.

```

---

<div class="post-metadata">

**Author:** ![abr](https://resource.dopus.com/user_avatar/resource.dopus.com/abr/32/62448_2.png) [@abr](https://resource.dopus.com/u/abr)\
**Post date:** [December 11, 2024, 5:10pm UTC](https://resource.dopus.com/t/powershell-with-a-predefined-command/53761/9 "2024-12-11T17:10:27Z")

</div>

Yes, -NoExit at the beginning of the command line did the trick. Thanks to all!

---

<div class="post-metadata">

**Author:** ![tbone](https://resource.dopus.com/user_avatar/resource.dopus.com/tbone/32/25726_2.png) [@tbone](https://resource.dopus.com/u/tbone)\
**Post date:** [December 13, 2024, 2:48am UTC](https://resource.dopus.com/t/powershell-with-a-predefined-command/53761/10 "2024-12-13T02:48:28Z")

</div>

In powershell you can run regular executables as well of course, just like you can run "notepad.exe" in powershell or in a regular command prompt (cmd.exe). So, that's why running "dism.exe" works, it's a regular executable file somewhere in your PATH, but it's not related to powershell in any specific way.

This works, as you found out..  
`powershell -noexit -command dism ..`

..but you probably get the same result (terminal window staying open) if you use an "MS-DOS Batch Function" type button and this code:

```auto
@leavedoswindowopen
dism ..

```

![image](https://resource.dopus.com/uploads/default/original/3X/4/a/4a31af6c6afa753459944fc8acef1a61bd901b59.png)

---

<div class="post-metadata">

**Author:** ![tbone](https://resource.dopus.com/user_avatar/resource.dopus.com/tbone/32/25726_2.png) [@tbone](https://resource.dopus.com/u/tbone)\
**Post date:** [December 13, 2024, 3:00am UTC](https://resource.dopus.com/t/powershell-with-a-predefined-command/53761/11 "2024-12-13T03:00:56Z")

</div>

For more tweaks and disabling some more unwanted Windows Features, I think the Chris Titus WinUtil is worth mentioning here. It has a ton of options and convenience-clicks..

Make sure the window is big enough to see all the options or use of the scroll bar to the right, which can easily be overlooked, it is a bit too dark and slim for my taste to be recognized easily.

 ![image](https://resource.dopus.com/uploads/default/original/3X/f/0/f0b80c295c69f50ab9c478ccd7d6e8265fc24272.png)

> **[GitHub - ChrisTitusTech/winutil: Chris Titus Tech's Windows Utility - Install...](https://github.com/ChrisTitusTech/winutil)**
>
> Chris Titus Tech's Windows Utility - Install Programs, Tweaks, Fixes, and Updates

---

<div class="post-metadata">

**Author:** ![abr](https://resource.dopus.com/user_avatar/resource.dopus.com/abr/32/62448_2.png) [@abr](https://resource.dopus.com/u/abr)\
**Post date:** [December 13, 2024, 3:31am UTC](https://resource.dopus.com/t/powershell-with-a-predefined-command/53761/12 "2024-12-13T03:31:10Z")

</div>

Thanks, i could test that too. I need it to check if that function stays disabled after Win updates. ~~Not sure about how to use WinUtil, i only found that ps1 script, no installer.~~. Ok, got it.
