Page 1 of 2 12 LastLast
  1.    23 Apr 2017 #1
    Join Date : Apr 2017
    Posts : 11
    Windows 10, Debian 9

    && Weirdness


    Code:
    runas /user:Administrator "defrag c: /V"
    This works.
    Code:
    runas /user:Administrator "cleanmgr /VERYLOWDISK"
    This works.
    Code:
    runas /user:Administrator "defrag c: /V" && "cleanmgr /VERYLOWDISK"
    This does not work.

    I've tried /savecred thinking it might be some silly privilege issue, but that doesn't work either.
    Where did I go wrong?
      My ComputerSystem Spec
  2.    23 Apr 2017 #2
    Join Date : Jun 2014
    Posts : 546
    Microsoft Windows 10 Pro 64-bit

    Try a semicolon ​; ​ in powershell
    Last edited by sml156; 23 Apr 2017 at 17:48.
      My ComputerSystem Spec
  3.    23 Apr 2017 #3
    Join Date : Aug 2016
    S/E England
    Posts : 4,524
    10 Home x64 (1709) (10 Pro on 2nd pc)

    In a command prompt a single & acts as a delimiter between two commands, effectively allowing you to enter a sequence of commands on one line as if you had typed each command after the previous one had completed.

    The double && is similar, but will only execute the command following the && if the previous command was successful. It may be that your first command didn't return a 'success' code.

    You can use the special characters listed in the following table to pass multiple commands.

    Character Syntax Definition
    & [...] command1 & command2 Use to separate multiple commands on one command line.
    Cmd.exe runs the first command, and then the second
    command.
    && [...] command1 && command2 Use to run the command following && only if the command
    preceding the symbol is successful. Cmd.exe runs the first
    command, and then runs the second command only if the first
    command completed successfully.
    || [...] command1 || command2 Use to run the command following || only if the command
    preceding || fails. Cmd.exe runs the first command, and then
    runs the second command only if the first command did not
    complete successfully (receives an error code greater than zero).
    ( ) [...] (command1 & command2) Use to group or nest multiple commands.
    ; or , command1
    parameter1;parameter2
    Use to separate command parameters.
    https://www.microsoft.com/resources/...loverview.mspx
      My ComputersSystem Spec
  4.    23 Apr 2017 #4
    Join Date : Apr 2017
    Posts : 11
    Windows 10, Debian 9
    Thread Starter

    Try a semicolon ​; ​ in powershell
    That's good to know, but it appears to skip over the second command in PowerShell.

    In a command prompt a single & acts as a delimiter between two commands, effectively allowing you to enter a sequence of commands on one line as if you had typed each command after the previous one had completed.

    The double && is similar, but will only execute the command following the && if the previous command was successful. It may be that your first command didn't return a 'success' code.
    If I use & instead of && in CMD, it still skips the second command and gives me this error.
    >The system cannot find the path specified.

    Code:
    runas /user:Administrator ("defrag c: /V" & "cleanmgr /VERYLOWDISK")
    If I use nesting, neither command works and I get two cannot find path errors.
      My ComputerSystem Spec
  5.    23 Apr 2017 #5
    Join Date : Dec 2013
    Portsmouth Hampshire
    Posts : 1,835
    Windows 10 x86 14383 Insider Pro and Core 10240

    Observation (may or may not affect outcome):

    If you run the cleanmgr command first, and some files are removed, followed by the defrag command, if successful, there will be fewer files to defrag, and there will be more space on disk for defrag to operate with, and fill gaps, resulting in a faster overall time, and a neater result on disk than the other way around..
      My ComputersSystem Spec
  6.    23 Apr 2017 #6
    Join Date : Apr 2017
    Posts : 11
    Windows 10, Debian 9
    Thread Starter

    If you run the cleanmgr command first, and some files are removed, followed by the defrag command, if successful, there will be fewer files to defrag, and there will be more space on disk for defrag to operate with, and fill gaps, resulting in a faster overall time, and a neater result on disk than the other way around..
    Yes, the ordering was not very bright on my part. The outcome is still the same with only the first command being run.
      My ComputerSystem Spec
  7.    23 Apr 2017 #7
    Join Date : May 2015
    Central IL
    Posts : 4,254
    Mac OS Sierra

    Quote Originally Posted by jnich View Post
    Yes, the ordering was not very bright on my part. The outcome is still the same with only the first command being run.
    Running those commands all of the time is just wearing down your hard drive, especially if you have a SSD. You should never run those commands, unless you have made major changes such as an upgrade to the next step version of Windows 10, or have removed a bunch of files that have been moved to another drive.
      My ComputerSystem Spec
  8.    23 Apr 2017 #8
    Join Date : Apr 2017
    Posts : 11
    Windows 10, Debian 9
    Thread Starter

    Running those commands all of the time is just wearing down your hard drive, especially if you have a SSD. You should never run those commands, unless you have made major changes such as an upgrade to the next step version of Windows 10, or have removed a bunch of files that have been moved to another drive.
    I'm keenly aware. My intention is to write a one liner or batch script which does manual routine maintenance like defrag (on HDD), disk clean, defender update and scan, and windows update. I would like to write out a log of each process as well, but this is a secondary issue.
      My ComputerSystem Spec
  9.    23 Apr 2017 #9
    Join Date : May 2015
    Central IL
    Posts : 4,254
    Mac OS Sierra

    Quote Originally Posted by jnich View Post
    I'm keenly aware. My intention is to write a one liner or batch script which does manual routine maintenance like defrag (on HDD), disk clean, defender update and scan, and windows update. I would like to write out a log of each process as well, but this is a secondary issue.
    You do not need to do one, since it actually causes Windows 10 to screw up its built in housekeeping duties and slows down your system. As I stated before, you do not have to do any of this, since Windows 10 automatically looks at the hard drive and defrags it as part of its housekeeping when booting up or shutting down it records that info for it to happen the next time you turn the system back on or reboot.

    The only time you have to use Disk Cleanup is after a in place upgrade or doing a clean install and having updates installed, along with installing programs on the machine.
      My ComputerSystem Spec
  10.    23 Apr 2017 #10
    Join Date : Apr 2017
    Posts : 11
    Windows 10, Debian 9
    Thread Starter

    Quote Originally Posted by bro67 View Post
    You do not need to do one, since it actually causes Windows 10 to screw up its built in housekeeping duties and slows down your system. As I stated before, you do not have to do any of this, since Windows 10 automatically looks at the hard drive and defrags it as part of its housekeeping when booting up or shutting down it records that info for it to happen the next time you turn the system back on or reboot.

    The only time you have to use Disk Cleanup is after a in place upgrade or doing a clean install and having updates installed, along with installing programs on the machine.
    Please forget the programs I'm using since they are irrelevant to the issue at hand.
    Code:
    mkdir new && cd new && echo 'test' > 1.txt
    Why would this work as a regular user?
    Code:
    runas /user:Administrator mkdir new && cd new && echo 'test' > 1.txt
    ...but not this?
    Code:
    runas /user:Administrator "mkdir new && cd new && echo 'test' > 1.txt"
    ..or this?
      My ComputerSystem Spec

 
Page 1 of 2 12 LastLast


Similar Threads
Thread Forum
OLD CorelDraw installation weirdness
I have two desktop computers. A new one that came with Windows 10 installed. The other was Windows 7 until I did the upgrade. I tried to install CorelDraw X3 (yeah, it's really old...) on the new computer, but it wouldn't install ... not compatible....
Software and Apps
Keyboard Weirdness
Hi all, I'm having an issue with keyboards. They will randomly stop working. At first I had a wired keyboard and had to physically remove it from the USB slot (then plug it back in). Now I have a wireless keyboard, and I can fix the issue...
Drivers and Hardware
Reading App Weirdness
I was rereading a multi-chapter fanfic I wrote on AO3 using the reading app which I love, by the way. However, when I got to Chapter 16 and clicked on the app button, it loaded a blank page. Upon trying it several times, it either loaded a blank...
Software and Apps
Key Mapping Weirdness
I am having a very odd problem with a brand new laptop which installed Windows 10 when I powered it up. The laptop is a Dell Inspiron 15. Because I'm in Canada, someone, presumably the government, decided that all computers sold in Canada had to...
Drivers and Hardware
Autoplay weirdness
Hi all Does anybody have a registry script or know of a fixit that will repair autoplay functionality? For some reason my Windows 10 installation will not autoplay mechanical drives, but behaves perfectly with standard USB sticks! I hear the...
Drivers and Hardware
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 15:42.
Find Us
Twitter Facebook Google+ Ten Forums iOS App Ten Forums Android App



Windows 10 Forums