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

Page 1 of 2 12 LastLast

  1. Posts : 364
    Windows 10 home 1803/17134.48
       28 Feb 2018 #1

    Can't run command in PowerShell but OK in Cmd


    Click image for larger version. 

Name:	Quick PS.jpg 
Views:	82 
Size:	49.5 KB 
ID:	178957Click image for larger version. 

Name:	Quick Cmd.jpg 
Views:	76 
Size:	45.3 KB 
ID:	178956

    The screen shots show results of running
    Code:
    "C:\Program Files\AVAST Software\Avast\ashCmd.exe" /@=Quick
    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 /@?
      My ComputerSystem Spec

  2.   My ComputerSystem Spec

  3.    01 Mar 2018 #3

    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
      My ComputerSystem Spec


  4. Posts : 364
    Windows 10 home 1803/17134.48
    Thread Starter
       01 Mar 2018 #4

    I tried the suggested command and it does work manually in Power Shell. But Task Scheduler chokes on it.

    Click image for larger version. 

Name:	Add &.jpg 
Views:	43 
Size:	32.3 KB 
ID:	179039

    If i say "Yes" it breaks up the command string to "%C:\program" with the rest of the command as an argument.
      My ComputerSystem Spec

  5.    01 Mar 2018 #5

    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--
      My ComputersSystem Spec

  6.    01 Mar 2018 #6

    Try this PowerShell.exe &"C:\Program Files\AVAST Software\Avast\ashCmd.exe" /@=Quick at the Task Scheduler.
      My ComputerSystem Spec

  7.    01 Mar 2018 #7

    FreeBooter said: View Post
    Try this PowerShell.exe &"C:\Program Files\AVAST Software\Avast\ashCmd.exe" /@=Quick at the Task Scheduler.
    Might as well just run cmd.exe with /c "C:\Program Files\AVAST Software\Avast\ashCmd.exe" /@=Quick as the arguments then then.
      My ComputerSystem Spec

  •    01 Mar 2018 #8

    PolarNettles said: View Post
    Might as well just run cmd.exe with /c "C:\Program Files\AVAST Software\Avast\ashCmd.exe" /@=Quick as the arguments then then.
    OP said for some reason command-line does not work why i have no idea.
      My ComputerSystem Spec

  •    01 Mar 2018 #9

    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.
    Last edited by dalchina; 01 Mar 2018 at 23:47.
      My ComputerSystem Spec


  • Posts : 364
    Windows 10 home 1803/17134.48
    Thread Starter
       01 Mar 2018 #10

    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.
      My ComputerSystem Spec


  •  
    Page 1 of 2 12 LastLast

    Related Threads
    How do you change from PowerShell to Command Prompt using file explorer ?
    Hello, I'm looking for a way to check PC's IP Geolocation by using command prompt or powershell (no scripts). I hope there are some experts here who can help me out. I have found a very easy to do it on UNIX systems but my main machines will be...
    :really:I have a few PCs connected via a bridge on an ethernet LAN. They communicate with each other, not "the internet". I'd like to rename "Unidentified network" to something more reasonable like "DoNotTreadOnMe" (allegorical.) 76590
    I've encounter that all of my windows 10 apps cannot launch. I click them in the start menu but without response. I've executed powershell command Get-AppXPackage -AllUsers | Foreach {Add-AppxPackage -DisableDevelopmentMode -Register...
    Show Command Prompt or PowerShell in Win+X Power User Tasks Menu in Windows 10 This tutorial will show you how to have either the Command Prompt or Windows PowerShell items show in your Win+X Power User Tasks menu in Windows 10 ...
    Our Sites
    Site Links
    About Us
    Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

    © Designer Media Ltd
    All times are GMT -5. The time now is 20:59.
    Find Us