1

I want to start the control panel applet RunDll32.exe shell32.dll,Control_RunDLL via an alias in PowerShell. Running it directly works fine but when I set an alias:

set-Alias controlpanel "RunDll32.exe shell32.dll,Control_RunDLL"

and execute it, I get the standard error message The term 'RunDll32.exe shell32.dll,Control_RunDLL' is not recognized as the name of a cmdlet,...(snip)

I figured out that this is due to the space in between the runDLL.exe and shell.dll. Is it possible to add alias with the space somehow?

3
  • the Set-Alias cmdlet is for making an alias to a single & simple thing. if you want to use something more than just that - like a macro - you will need to make a function that contains the desired complex command & either create an alias for that with the Set-Alias cmdlet OR use the [Alias()] attribute in the function definition. [grin]
    – Lee_Dailey
    Commented May 8, 2022 at 3:34
  • Thx I figured that out already (see my answer)
    – Albin
    Commented May 8, 2022 at 5:38
  • yep, i saw that ... just wanted to add a different way to state the same thing & mention the [Alias()] attribute inside the function can have the same effect as Set-Alias. [grin]
    – Lee_Dailey
    Commented May 8, 2022 at 5:57

2 Answers 2

2

Since an alias allows for another name for one ("single") command. So in a way it's understandable that this does not include parameters. (Although I'm not sure why PowerShell doesn't parse the second string as a parameter anyway are there any 2 words commands?)

The solution is to use a function which in my case would be Function controlpanel { RunDll32.exe shell32.dll,Control_RunDLL }.

0

You must create a function that contains the command with parameters.

https://learn.microsoft.com/en-us/powershell/scripting/learn/shell/using-aliases?view=powershell-7.3#creating-alternate-names-for-commands-with-parameters

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .