Windows 10: Can't run command in PowerShell but OK in Cmd

Discus and support Can't run command in PowerShell but OK in Cmd in Windows 10 Support to solve the problem; [img] [img] The screen shots show results of running Code: "C:\Program Files\AVAST Software\Avast\ashCmd.exe" /@=Quick[/quote] in both PS and... Discussion in 'Windows 10 Support' started by tcebob, Feb 27, 2018.

  1. tcebob Win User

    Can't run command in PowerShell but OK in Cmd


    Can't run command in PowerShell but OK in Cmd [​IMG]

    Can't run command in PowerShell but OK in Cmd [​IMG]


    The screen shots show results of running Code: "C:\Program Files\AVAST Software\Avast\ashCmd.exe" /@=Quick[/quote] in both PS and Cmd. The problem is I have made a task in Task Scheduler to run this command daily and, apparently, Task Scheduler insists on using PS. This has worked for a couple of years but after recent updates has stopped.

    How can I force Task Scheduler to use Cmd? Or how can I fix PS to recognize /@?

    :)
     
    tcebob, Feb 27, 2018
    #1
  2. Jane Lla Win User

    problems and suggestion

    There is a DOS command you can use to run as administrator in command line, follow provided steps by Leo Huang on this

    thread
    .

    Let us know how it goes.
     
    Jane Lla, Feb 27, 2018
    #2
  3. houss1 Win User
    problems and suggestion

    1.i don't know

    2.the problem is not in windows store apps

    3.i want to be gaming in safe mode but i can't there is no sound and i don't try that yet

    4.also when type cmd in search and click on run as administrator the file explorer restarts and also when clicking on windows PowerShell and windows PowerShell administrator

    5.i can't enter cmd as administrator but i can enter to cmd and PowerShell as admin and is there any command to change to admin in cmd
     
    houss1, Feb 27, 2018
    #3
  4. dalchina New Member

    Can't run command in PowerShell but OK in Cmd

    dalchina, Feb 28, 2018
    #4
  5. PowerShell interprets the "C:\Program Files\AVAST Software\Avast\ashCmd.exe" part as a string. You have to use the call operator "&" to tell it to treat it as a command.

    Code: &"C:\Program Files\AVAST Software\Avast\ashCmd.exe" /@=Quick[/quote]
     
    PolarNettles, Feb 28, 2018
    #5
  6. tcebob Win User
    I tried the suggested command and it does work manually in Power Shell. But Task Scheduler chokes on it.


    Can't run command in PowerShell but OK in Cmd [​IMG]


    If i say "Yes" it breaks up the command string to "%C:\program" with the rest of the command as an argument.
     
    tcebob, Feb 28, 2018
    #6
  7. EdTittel Win User
    This is looking increasingly like an "escape character" issue where multiple levels of escapement are coming into play (one level inside PowerShell, another inside Task Scheduler). I'd suggest zooming over to the forums at PowerShell.org where the real PS wizards congregate and deal with stuff like this regularly. I bet if you ask them, you'll get a straight answer pronto (and may even find it covered there already).
    HTH,
    --Ed--
     
    EdTittel, Feb 28, 2018
    #7
  8. Can't run command in PowerShell but OK in Cmd

    Try this PowerShell.exe &"C:\Program Files\AVAST Software\Avast\ashCmd.exe" /@=Quick at the Task Scheduler.
     
    FreeBooter, Feb 28, 2018
    #8
  9. Might as well just run cmd.exe with /c "C:\Program Files\AVAST Software\Avast\ashCmd.exe" /@=Quick as the arguments then then.
     
    PolarNettles, Feb 28, 2018
    #9
  10. OP said for some reason command-line does not work why i have no idea.
     
    FreeBooter, Feb 28, 2018
    #10
  11. dalchina New Member
    Hi, create a bat file containing
    cmd.exe /c "C:\Program Files\AVAST Software\Avast\ashCmd.exe" /@=Quick

    and schedule the bat file.I don't have ashCmd.exe but
    cmd.exe /c "D:\Utilities\Sysinternals Suite\psinfo" /?
    in a bat file works from the task scheduler.
     
    dalchina, Feb 28, 2018
    #11
  12. tcebob Win User
    dalchina, your idea is brilliant and simple. The batch file works fine when run from the desktop. But, alas, does not run from the task scheduler. It says "Running" but nothing happens. Task scheduler shows in Task Manager while it's running.

    ... Edited out the /@=Quick part and still won't run. So maybe it has something to do with the ashCmd.exe program or with Avast.
     
    tcebob, Feb 28, 2018
    #12
  13. lx07 Win User

    Can't run command in PowerShell but OK in Cmd

    Try --%

    That tells Powershell not to try to parse the rest of the line but just pass it as is.

    So Code: "C:\Program Files\AVAST Software\Avast\ashCmd.exe" --% /@=Quick[/quote]
     
  14. tcebob Win User
    Good to know, lxo7. I'll try it. But right now I've avoided the problem by downloading System Scheduler Splinterware which ran the command perfectly, using "c:\program files\avast software\avast\ashcmd.exe" as the application and /@=Quick as the parameter. It used cmd automatically.
     
    tcebob, Mar 1, 2018
    #14
  15. dalchina New Member
    Strange. You could convince yourself the bat file is executed by picking something without a parameter that can be run from a command line- even just
    DIR C:
    Pause

    say.

    Just wondering if there's a difference in running as admin or a standard user for ashCmd?
    I have Avast free, but not that for whatever reason.
     
    dalchina, Mar 1, 2018
    #15
Thema:

Can't run command in PowerShell but OK in Cmd

Loading...
  1. Can't run command in PowerShell but OK in Cmd - Similar Threads - Can't run command

  2. CMD command doesn't work on PowerShell

    in Windows 10 Gaming
    CMD command doesn't work on PowerShell: I'm trying to call 'cmd' inside Windows PowerShell console in order to get to work immediately with Command Prompt mode, but I got this message instead:I know I can use Command Prompt outside of PowerShell, but this is a special case.Any suggestions about how can I revert...
  3. CMD command doesn't work on PowerShell

    in Windows 10 Customization
    CMD command doesn't work on PowerShell: I'm trying to call 'cmd' inside Windows PowerShell console in order to get to work immediately with Command Prompt mode, but I got this message instead:I know I can use Command Prompt outside of PowerShell, but this is a special case.Any suggestions about how can I revert...
  4. Can't run almost any commands in cmd/powershell

    in Windows 10 Gaming
    Can't run almost any commands in cmd/powershell: Basically, adb : The term 'adb' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:1 + adb + ~~~ + CategoryInfo :...
  5. Can't run almost any commands in cmd/powershell

    in Windows 10 Software and Apps
    Can't run almost any commands in cmd/powershell: Basically, adb : The term 'adb' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:1 + adb + ~~~ + CategoryInfo :...
  6. Powershell can't run appx commands

    in Windows 10 BSOD Crashes and Debugging
    Powershell can't run appx commands: So a few windows processes are hogging up all my memory and cpu such as the gaming services which I never use I do play Minecraft java But I doubt it uses gaming services. So I wanted to get rid of those. I tried running some appx commands which were given on the forum And...
  7. Powershell can't run appx commands

    in Windows 10 Gaming
    Powershell can't run appx commands: So a few windows processes are hogging up all my memory and cpu such as the gaming services which I never use I do play Minecraft java But I doubt it uses gaming services. So I wanted to get rid of those. I tried running some appx commands which were given on the forum And...
  8. Powershell can't run appx commands

    in Windows 10 Software and Apps
    Powershell can't run appx commands: So a few windows processes are hogging up all my memory and cpu such as the gaming services which I never use I do play Minecraft java But I doubt it uses gaming services. So I wanted to get rid of those. I tried running some appx commands which were given on the forum And...
  9. Powershell with CMD/c to run external command with Parameters

    in Windows 10 Customization
    Powershell with CMD/c to run external command with Parameters: Greeting, I have an old command line application call Commandline.exe. it run with a parameter to check then show the result. but it need extra "Enter" to confirm like: commandline.exe -s 4567890 So I preparing the an answer file which is on an "Enter" crlf...
  10. Cannot run linux command directly from cmd/powershell

    in Windows 10 BSOD Crashes and Debugging
    Cannot run linux command directly from cmd/powershell: Recently, I upgraded my windows to 2004 from 1909. I notice that I cannot run command like "xxx grep xx" from command line anymore. Initially I thought that is because I have WSL2 Ubuntu distro now, but converting Ubuntu to WSL1 didn't help the problem. On Win10 2004:...

Users found this page by searching for:

  1. how to run a command file in powershell

    ,
  2. running cmd command in powershell

    ,
  3. scanner virus cmd