How to copy one directory to another with window command prompt?

How to copy one directory to another with window command prompt?

I read alot of guides about to copy directories. On SO also read the posts

Commmand line command to copy entire directory (including directory folder) to another directory
copying all contents of folder to another folder using batch file?


but nothing is working for me. I am using Window 10 Pro 64bit version. My directory looks like
myfolder
   |
    ---folder1
    ---folder2
         |
         ---sample.txt

The expected output is
myfolder
   |
    ---folder1
         |
         ---folder2
             |
             ---sample.txt
    ---folder2
         |
         ---sample.txt

At command prompt, my present working directoy is 
C:Users\MyName\Desktop\myfolder>

When I tried with belows
robocopy folder2 folder1 /COPYALL /E
xcopy folder2 folder1 /s /i

only sample.txt was copied to folder1. What's I am wrong ?

Solutions/Answers:

Answer 1:

Only sample.txt was copied to folder1

You need to properly specify the target directory name.

Use one of the following commands:

robocopy folder2 folder1\folder2 /COPYALL /E

Or:

xcopy folder2 folder1\folder1 /s

Further Reading

Answer 2:

xcopy copies only content of folder2 to folder1. You should try this, as now you are under myfolder:

cd folder1
xcopy ..\folder2 folder2 /S /I

Answer 3:

Either of the above would work.
My preference is to user wildcards, where appropriate.

xcopy /s folder2\* folder1\

Our Awesome Tools

References

Windows 10, cannot run any .exe from secondary drives

Windows 10, cannot run any .exe from secondary drives

When I try to run any exe from any secondary (non C:) drive or partition, I get a message box with Windows cannot access the specified device, path or file. You, may not have the appropiate permissions for the item if I try to run it from cmd I get Access is denied..
Additional info:

I'm administrator.
I have full control over the files.
Tried it with a known exe  (wordpad). Copied it on the Desktop and it worked. From anywhere on the secondary partition of the local HDD, or a removable USB didn't.
This worked 3 months ago, not sure when it stopped working
I'm the owner of the file

(edit: added that I'm the owner of the file)

Solutions/Answers:

Answer 1:

If the solution of darmual did not cut it quite for me. The group policies did not change the registry entries needed to grant execute rights for removable media devices (for some reason my second hard drive was also considered a removable device).

In order to gain write access to executable files in your “removable” media under windows 10 you should change the following register entries:

  • HKLM\SYSTEM\CurrentControlSet\Control\Storage
  • HKLM\SOFTWARE\Policies\Microsoft\Windows\RemovableStorageDevices{53f5630d-b6bf-11d0-94f2-00a0c91efb8b}
  • HKLM\SOFTWARE\WOW6432Node\Policies\Microsoft\Windows\RemovableStorageDevices{53f5630d-b6bf-11d0-94f2-00a0c91efb8b}

Deny_Execute

set it to 0

Registry entry example

This solution worked for me and hopefully will fix your problem as well.

Edit (14.05.2018):

Here are the keys entries and their corresponding values. Save the lines of code into a .reg file and you will be able to change them all at once:

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Storage]
"Deny_Execute"=dword:00000000


[HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Policies\Microsoft\Windows\RemovableStorageDevices\{53f5630d-b6bf-11d0-94f2-00a0c91efb8b}]
"Deny_Execute"=dword:00000000


[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\RemovableStorageDevices\{53f5630d-b6bf-11d0-94f2-00a0c91efb8b}]
"Deny_Execute"=dword:00000000

Answer 2:

The problem was caused by a Local Group Policy Admistrative Template, Local Computer Policy\Computer Configuration\Administrative Templates\System\Removable Storage Access\Removable Disks: Deny execute access, which was manually set to enable.

After resetting it to Not Configured and rebooting the problem disappeared.

Apparently the secondary partition from my main hard drive was also considered a “Removable Disk”.

Answer 3:

None of these worked for me. However here someone suggests running from the command line, which is the best workaround I could find.

Open Command Prompt as Administrator (right click on the shortcut for the option), switch to the drive (type D:), cd to the directory (type cd \path\to\dir, and type start filename.exe

Our Awesome Tools

References

How to configure a bluetooth mouse in Windows 10 on MacBook Pro with Bootcamp?

How to configure a bluetooth mouse in Windows 10 on MacBook Pro with Bootcamp?

I have a mouse (Microsoft Sculpt Comfort Mouse) that I wish to connect to my MacBook Pro when I switch to Windows with Bootcamp. I can see the mouse when I look for devices but it stays on "Connecting" and never pairs. What can I do?

Solutions/Answers:

Answer 1:

It took a lot of searching, but here goes. First, cover the basics:

  1. Update drivers and Windows stuff with Windows Update
  2. Update Bootcamp drivers with Apple Software Update

Then, the not so subtle part:

  1. Switch to Mac if your mouse is already paired there and unpair it. You can try and re-pair it later.
  2. Switch to Windows, pair the mouse.
  3. Reboot

If the mouse is paired, congrats. It may however turn off if you’re running on the battery. That’s power management throwing one last monkey wrench in the works.

For this, go in the Device Manager, open Bluetooth then Bluetooth radio, open its properties, go in the Power Management tab and uncheck “Allow the computer to turn off this device to save power.”

enter image description here

Our Awesome Tools

References

Autohotkey script not running on startup

Autohotkey script not running on startup

So I have two scripts in shell:startup. One that is a bunch of hotkeys to do various things when I push ctrl+c/a/s/etc. and the other is meant to run something once at boot up and that's it.
The problem is that the on boot script is not working. Nothing happens from it on power on.
If I run the script manually it does work as intended. I tried adding a sleep as I thought maybe it was running before some required stuff was loaded, but still no luck, even with a 10 minute delay. The script never does anything, it is never shown in the taskbar.
What is the problem?
I can provide the script if necessary, but since it doesn't look like it loads at all I don't think its a coding problem.

Solutions/Answers:

Answer 1:

I had same problem in win10, the solution is to edit the startup registry directly.

  1. run regedit
  2. browse to
    Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run
  3. Add new String Value
  4. For Value Data, input path to your .ahk file

That’s it.

Answer 2:

Not sure if you had this running in anything prior to Windows 10, but when I upgraded from Windows 7 I found that some of my AutoHotKey scripts stopped working on load. I finally figured out it was because they now needed admin rights (I don’t think they needed them in Win7), but Win10 blocks the items in the shell:startup and shell:common startup locations from running as admin.

My solution is a little convoluted but works well. Basically, I left my script in a normal (non-startup) location, such as C:\Users\xyz\Documents and then created a shortcut to the script in that same location. You can then set the properties of the shortcut to run as admin. Finally, in the shell:startup location, I created a batch file that would autorun and call the shortcut:

start "MyScript" /D "C:\Users\xyz\Documents\" /B MyScript.ahk.lnk

Our Awesome Tools

References

How to sync windows 10 clock to internet from commandline?

How to sync windows 10 clock to internet from commandline?

I would like to be able to synchronize my windows 10 computer clock when it goes out of sync... From the commandline with 1 command.
This solution shows how to do it via settings.
https://superuser.com/a/1050717/44355
Is there a way to perform this via some windows 10 api on the commandline?

Solutions/Answers:

Answer 1:

Start a PowerShell with elevated rights and use the W32tm command:

W32tm /resync /force

For further reading: interesting article about the difference between NET TIME and W32tm.

Our Awesome Tools

References

Is it smart to use NTFS compression on a bitlocker encrypted disk?

Is it smart to use NTFS compression on a bitlocker encrypted disk?

My intuition says that this should serve no benefit. However I just clean installed windows 10 pro and all of my non-system files are compressed. I'm getting almost 50% compression on my ssd. 
If they are encrypted, how could this be possible?
Am I correct in thinking there shouldn't be any benefit, eventhough it looks like there is?

Solutions/Answers:

Answer 1:

I think I understand your logic, but the order of things is important…

After encryption encrypted files look like if they are containing random data. And random data doesn’t compress well.
So storing already encrypted files in a compressed-archive format (like ZIP, RAR or 7Z) doesn’t yield much benefit in terms of compression ratio. Storage space may actually increase instead of decrease.

But here you have things the other way around:
Files are compressed first (at the NTFS level, before actually saving them) to make them smaller.
Then these compressed files are stored on a disk with full-disk encryption.
The encryption process doesn’t know (or care) what it is encrypting. To BitLocker, which operates at the block-level below the filesystem, it is all just blocks of data and the content is irrelevant. The encrypted block while be exactly the same size as the original un-encrypted block, just the content will be scrambled.
So you get the space-saving of the compression and the encryption and they don’t affect each other.

Answer 2:

If your dataset will benefit from compression then using NTFS compression will still provide that benefit, because of the order data is written in.

If you think about this as acting at different layers, it may be clear why.

Data to Be Saved -> NTFS Compressed Filesystem -> Bitlocker Encryption -> Disk

Because (when writing) the NTFS Compression is taking place before Bitlocker encryption, the files will indeed be smaller.

To clarify, although encryption may look pretty much random on a raw disk, by the time it is written on, Bitlocker is decrypted it, so the data does not look random to the OS, and thus it can benefit from encryption.

Our Awesome Tools

References

some start menu icons on Windows 10 are sometimes Blank

some start menu icons on Windows 10 are sometimes Blank

i am using windows 10 version 1803 and some of my start menu icons are sometimes blank. Not my Windows icons but some icons from installed program.

Solutions/Answers:

Answer 1:

I fixed it.

  1. Right click on the taskbar.
  2. Click on Taskbar Settings.
  3. Go to the Start Menu settings (on the left-hand side)
  4. Turn on Use Start full screen.
  5. Lave the settings and display your start menu as full screen.
  6. Go back to the settings and turn Use Start full screen back off.

Answer 2:

Well, I can’t figure out how to do it permanently, but this seems to work for me. I created a file in notepad and saved it as “restart_explorer.bat” and then pasted these 2 lines in there.

taskkill /f /im explorer.exe 
start explorer.exe

If it’s not restarting your explorer, then you can add a 3rd line with the word pause to see what errors you’re getting.

taskkill /f /im explorer.exe 
start explorer.exe
pause

This seems to reset my icons, for now. I leave it on my desktop and run it whenever they go blank.

Our Awesome Tools

References

How to fix “Deny Everyone” permissions in registry

How to fix “Deny Everyone” permissions in registry

So here's a spicy one for you guys...
I changed permissions on a registry folder (HKEY_CURRENT_USER\Control Panel\Keyboard) to "Deny Everyone". I had a good reason for doing it (long story) but it didn't resolve my issue (somehow the system is still changing it... mind boggling).
How can I fix this/can I fix this? I've tried everything I can think, including safe mode administrator account, but I can neither change the permissions nor reclaim ownership. I also tried the takeown command on the NTUSER.DAT file which is what I think contains that node, but while the command claimed success I'm still unable to access this registry folder or the keys inside.
Any ideas that don't involve reinstalling Windows? I'm on Windows 10.

Solutions/Answers:

Answer 1:

When you set EVERYONE DENY permissions you receive a warning that only the OWNER of the key will be able to change permissions or access it. On my Windows 10 system, the owner is SYSTEM. In most cases, it would be either SYSTEM, TRUSTED INSTALLER, or ADMINISTRATORS.

Therefore, we can fix this issue by running regedit as SYSTEM. In order to do so, we need to download pstools and extract the tools to a folder on your computer. On my system, I extracted them to D:\Downloads.

Now, we want to run Regedit as SYSTEM. To do this, open an administrative command prompt and change directories to where you expanded the PSTOOLS file (CD D:\Downloads). In that folder, is psexec. We will run the command psexec -i -s regedit.exe and Regedit will open.

Regedit is now running as the SYSTEM user. Therefore, HKEY_CURRENT_USER is not YOUR registry, it is the SYSTEM registry. Now we have to navigate to your registry key. We will find that under HKEY_USERS. This key holds the registry of all currently mounted (logged in) user registries.

Within HKEY_USERS you will find a series of keys that start with S-1-5-xxx and so on. The longer keys that end in -1001, -1002, etc. are your logged on users. Expand each one to find the one that corresponds with your user registry. You can open the Environment key under each one and you will most likely see an item with the name of what user the key is associated with. By this method you can find the right S-1-5-xxx key. At the very least, you can open each one, and check the permissions of Control Panel\Keyboard. You will definitely find which one has the bad permissions on it.

Now that you know how to find the Control Panel\Keyboard key that corresponds with your user account you can simply right-click it and change permissions. Remove the EVERYONE DENIED permission.

On a side note, the system is able to continue to make changes to the key because SYSTEM owns the key. If you are trying to prevent the system from making changes to this key, then what you want to do is change the ownership of the key to your own user name. Then deny SYSTEM from making changes to the key. However, you cannot deny “Full control” to SYSTEM or the system won’t even be able to read the key and no telling what will happen. Instead, you will need to go to “Advanced permissions” and deny the “Set Value” permission.

Answer 2:

I think you need some 3rd party tools (and OS) to edit registry when windows is offline. Try registry edit utility that can edit windows registry while it shutdowned.

Here is one that you can use:

https://pogostick.net/~pnh/ntpasswd/

You can also try to edit broken registry on another computer running Windows by “Load Hive” from File menu and feed it with registries from computer that need to be fixed. (But personally I prefer to do such things from non windows OS)

Standard precaution: In any cases be carefully when messing with registries.

Our Awesome Tools

References

Create MS Edge-specific URL shortcut

Create MS Edge-specific URL shortcut

I've created other browser-specific URL shortcuts for various purposes.
My current environment requires IE remain the default browser (yup) but some sites don't work with IE, so for those I create shortcuts that call the full path to Chrome.exe and then call the desired URL. The result being that activating that shortcut opens Google Chrome and navigates to the desired web page.
Microsoft Edge stores itself in an odd "app" location and cannot be called in the same way.
So, how does one create a shortcut for a specific URL that opens this URL in Microsoft Edge when some other browser is set as default?

Solutions/Answers:

Answer 1:

I believe you’d create a shortcut that looks like this:

%windir%\explorer.exe microsoft-edge:http://www.yoursite.com

Answer 2:

While asking this question I read this comment on a related question I’d found

You can launch a site using “microsoft-edge:www.cnn.com” Or
“%windir%\explorer.exe microsoft-edge:www.cnn.com” but I’ve found no
way to add -private parameter.

So, I created a shortcut using the following Target:

%windir%\explorer.exe "microsoft-edge:https://google.com"

And this worked.

Our Awesome Tools

References

Windows 10 Wifi Limited Connection – Wi-FI doesn’t have a valid IP configuration

Windows 10 Wifi Limited Connection – Wi-FI doesn’t have a valid IP configuration

Wifi was working via router in my house. Took it round to my friends house and it says Limited Connection.
Wireless network adaptor is Qualcomm Atheros QCA61x4 and current driver is 10.0.0.62. I tried updating (via GUI) this but it says I have the latest driver.
If I run Windows Network Diagnostics, it attempts to reset the wireless adaptor, and results in the following problem:
Wf-Fi doesn't have a valid IP configuration - Not Fixed

Running ipconfig /release prints:
An error occurred while releasing interface Wi-Fi : The system cannot find the file specified

I am finding that the problem is intermittent. I have just restarted the computer when it wasn't working and now the Wi-Fi connection is working.

Solutions/Answers:

Answer 1:

Reset your TCP/IP:

  1. Press your Windows-Key
  2. type cmd into the search programs and files field
  3. right-click the result and run as administrator
  4. in the following window type first: netsh winsock reset followed by pressing return – you will be told that you have to restart your computer; ignore it for the moment
  5. type netsh int ip reset followed by pressing return
  6. close the cmd window and reboot

If you had a static IP you would need to set it again.

Our Awesome Tools

References