I'm using Windows 10 on a device that has only one SSD formatted with NFTS, the drive letter is C:\
I have an application that looks for a file located in D:\afolder\needed.file (I can't change this)
Is there a way to put the file needed.file in C:\ and create a virtual link so that this application thinks is working on D:\afolder\needed.file but transparently the OS is redirecting it to the file located in C: ?
I tried with the command
mklink /H D:\afolder\needed.file C:\needed.file
but I receive the error
Local NTFS volumes are required to complete the operation.
Maybe it is because the drive D: doesn't exist at all on the device?
Is there a way to make it work?
NOTE: The SSD of the device is formatted with NTFS and I run the command mklink with admin privileges
Lets say there is a shared folder: \\server\share\folder1 containing Folder2\file.ext
I would like mount that folder to c:\somePath\someFolder
So that I can reference c:\somePath\someFolder\Folder2\file.ext
Best I can find is mounting to drive letter. :(
The access to the file is just an example. Let's just assume there are a few servers and a few files. Powershell or cmd is fine. Heck I would take cygwin too. :)
TIA
In cmd (run as as administrator) run the following command:
mklink /D c:\somePath\someFolder \\server\share\folder1
I installed MariaDB on my windows server and saw it defaults the datadir where the databases are stored to C:\Program Files\MariaDB 10.2\data
I wanted it moved the the E: disk that's dedicated to database stuff.
I thought copying the datadir and then modifying the my.ini in the C:\Program Files\MariaDB 10.2\data datadir would solve it, but when I tried to restart the service it wouldn't start.
I also tried setting the folder permissions to network service but that didn't seem to help.
What do I have to do to move my datadir on windows?
After a lot of searching I stumbled across http://baazgusht.blogspot.nl/2017/02/change-datadir-of-mariadb-in-window.html
It gave me the hint I needed to move the datadir on windows.
open cmd in administrator mode(start search cmd, rightlick execute as administrator)
type Net stop MariaDB (or whatever you named your service. for me it was net stop "MariaDB 10_2_7"
CD to C:\program files\mariadb 10.2\(or wherever your mariadb is installed)
Type: xcopy data E:\MariaDB /O /X /E /H /K (E:\MariaDb is my location, you may have another location. replace E:\MariaDB with whatever you want, just use the same value below for the datadir in my.ini)
Xcopy will ask when the destination doesn't exist if it should be a file or a folder. Choose the option that represents Folder.
Type: notepad data/my.ini
change the value of datadir=C:\Pro.... to datadir=E:\MariaDB
save (ctrl + s)
in CMD type net start mariadb (or whatever you named your service. for me it was net start "MariaDB 10_2_7"
I think that real problem is this one.
MariaDB use MySQL5.5 (or MariaDB10 for other version I use) as "group user" to set full permission on data folder. But this "group user" is not create under Windows "users and groups". So you cannot add this group on security tab and set permission to another folder.
Effectively, the workaround is to xcopy the original data folder to new location preserving the original permission.
But my problem is that I recover after a crash an older data folder. So it's not clear that workaround work (I wil try it tonight). I need to set the correct user group.
A true bug fix: fix intallation of MariaDB to effectivily create the "group user" in right place not just use it in folder permission.
Additional information to #Tschallacka's answer:
The copied my.ini file should be deleted from the target directory ("E:\MariaDb" in their example), since it is not honored by MariaDB. (It still contains the old path anyways.) And the contents of the source directory ("C:\Program Files\MariaDB 10.2\data" in their example) except my.ini should be deleted too, since those files are now found at the new path.
#Tschallacka's solution works because xcopy also copies permissions of the files. Windows Explorer does not.
Explanation of the options for xcopy:
/E Copies directories and subdirectories, including empty ones.
/H Copies hidden and system files also.
/K Copies attributes. Normal Xcopy will reset read-only attributes.
There are no hidden, system or read-only files in there right after install and there shouldn't after normal use and it shouldn't matter for the copied files, but it won't hurt.
/O Copies file ownership and ACL information.
The original directory has some additional permissions set. Without those, the MariaDB service seems to not be able to access the copied files properly.
/X Copies file audit settings (implies /O).
The service seems to start fine even without this option.
After some confusion with this error I can recommend that you:
Use slashes in Windows paths, for example C:/MariaDB/DB.
Experiment with adequate permissions. This seems to work:
cacls Path_to_MariaDB_DBData /E /T /P "Network Service":F
I am trying to change the icon that shows for the System Root, C:\Windows. I can't customize it like you normally would a Windows folder. I have looked for a registry entry I could add a DefaultIcon key too, but I haven't found anything.
I have tried using a desktop.ini file to do it, but it won't work:
[.ShellClassInfo]
IconResource=icon.ico,-0
The desktop.ini file and that icon were both in the Windows directory and it didn't change it, but those same pieces worked fine in the Downloads folder, so the code works.
Whatever the solution, I would like to avoid using any program to accomplish this.
I also would like to add a custom Icon to the "Program Files" folder and encounter the same issues.
Edit: I assumed, but in case there is a question: I am running Windows 7 (32 Bit)
Just copy the desktop.ini file into C:\WINDOWS like you did, then run Command Prompt as Administrator to type below command.
ATTRIB +R C:\WINDOWS
I am trying to run a batch file from a network share, but I keep getting the following message: "UNC path are not supported. Defaulting to Windows directory." The batch file is located on \\Server\Soft\WPX5\install.bat. While logged in as administrator, from my Windows 7 Desktop, I navigate to \\Server\Soft\WP15\ and double click on install.bat, that's when I get the "UNC path are not supported." message. I found some suggestions online stating that mapping drive will not work, but using a symbolic link will solve this issue, but the symbolic link didn't work for me. Below is my batch file content, I would appreciate any assistance that can help me accomplish what I am trying to do. Basically, I want to be able to run the batch file from \\Server\Soft\WP15\install.bat.
Batch file content
mklink /d %userprofile%\Desktop\WP15 \\server\soft\WP15
\\server\soft\WP15\setup.exe
robocopy.exe "\\server\soft\WP15\Custom" /copyall "C:\Program Files (x86)\WP\Custom Templates"
Regedit.exe /s \\server\soft\WPX5\Custom\Migrate.reg
Also, how do I remove the symbolic link after the install is completed?
PUSHD and POPD should help in your case.
#echo off
:: Create a temporary drive letter mapped to your UNC root location
:: and effectively CD to that location
pushd \\server\soft
:: Do your work
WP15\setup.exe
robocopy.exe "WP15\Custom" /copyall "C:\Program Files (x86)\WP\Custom Templates"
Regedit.exe /s WPX5\Custom\Migrate.reg
:: Remove the temporary drive letter and return to your original location
popd
Type PUSHD /? from the command line for more information.
I feel cls is the best answer. It hides the UNC message before anyone can see it. I combined it with a #pushd %~dp0 right after so that it would seem like opening the script and map the location in one step, thus preventing further UNC issues.
cls
#pushd %~dp0
:::::::::::::::::::
:: your script code here
:::::::::::::::::::
#popd
Notes:
pushd will change your working directory to the scripts location in the new mapped drive.
popd at the end, to clean up the mapped drive.
There's a registry setting to avoid this security check (use it at your own risks, though):
Under the registry path
HKEY_CURRENT_USER
\Software
\Microsoft
\Command Processor
add the value DisableUNCCheck REG_DWORD and set the value to 0 x 1
(Hex).
Note:
On Windows 10 version 1803, the setting seems to be located under HKLM:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Command Processor
Basically, you can't run it from a UNC path without seeing that message.
What I usually do is just put a CLS at the top of the script so I don't have to see that message. Then, specify the full path to files in the network share that you need to use.
I needed to be able to just Windows Explorer browse through the server share, then double-click launch the batch file. #dbenham led me to an easier solution for my scenario (without the popd worries):
:: Capture UNC or mapped-drive path script was launched from
set NetPath=%~dp0
:: Assumes that setup.exe is in the same UNC path
%NetPath%setup.exe
:: Note that NetPath has a trailing backslash ("\")
robocopy.exe "%NetPath%Custom" /copyall "C:\Program Files (x86)\WP\Custom Templates"
Regedit.exe /s %NetPath%..\WPX5\Custom\Migrate.reg
:: I am not sure if WPX5 was typo, so use ".." for parent directory
set NetPath=
pause
Instead of launching the batch directly from explorer - create a shortcut to the batch and set the starting directory in the properties of the shortcut to a local path like %TEMP% or something.
To delete the symbolic link, use the rmdir command.
I ran into the same issue recently working with a batch file on a network share drive in Windows 7.
Another way that worked for me was to map the server to a drive through Windows Explorer: Tools -> Map network drive. Give it a drive letter and folder path to \yourserver. Since I work with the network share often mapping to it makes it more convenient, and it resolved the “UNC path are not supported” error.
My situation is just a little different. I'm running a batch file on startup to distribute the latest version of internal business applications.
In this situation I'm using the Windows Registry Run Key with the following string
cmd /c copy \\serverName\SharedFolder\startup7.bat %USERPROFILE% & %USERPROFILE%\startup7.bat
This runs two commands on startup in the correct sequence. First copying the batch file locally to a directory the user has permission to. Then executing the same batch file. I can create a local directory c:\InternalApps and copy all of the files from the network.
This is probably too late to solve the original poster's question but it may help someone else.
This is the RegKey I used:
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Command Processor]
"DisableUNCCheck"=dword:00000001
My env windows10 2019 lts version and I add this two binray data ,fix this error
Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Command Processor DisableUNCCheck value 1
Computer\HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Command Processor
DisableUNCCheck value 1
This is a very old thread, but I still use Windows 7. :-)
There is one point that no one seems to have taken into account, which probably would help Windows 10 users also.
If Command Extensions are enabled, the PUSHD command accepts network paths in addition to the normal drive letter and path.
So the obvious - and simplest - answer might be to enable command extensions in the batch script, if you intend to use PUSHD. At the very least, this ought to reduce the problems you might have in using PUSHD wqith a network path.
I stumbled upon this question while searching for a solution to a specific problem. I needed to make a batch script that sits in a network folder (UNC path) with a Python script. The goal was to be able to double click on the batch script and have it run the Python script:
with the network folder containing the script as the working directory,
without modifications to the Python script (no command line parameters or hard-coded paths).
without creating another Python file.
The pushd and popd solutions were unsatisfactory. They work, but if the user were to get in the habit of forcefully terminating the script while it was running, they would end up with a bunch of mapped drives in My Computer since popd wasn't run.
I start by using cls to clear the UNC path error. I then assign the path containing the batch script to a variable. I slice the path to remove the trailing backslash (otherwise, Python throws a SyntaxError). Finally, I run a couple Python commands inside the batch file that change the working directory and execute the target script:
cls
#echo off
set pyfile=myscript.py
set batchdir=%~dp0
set wdir=%batchdir:~0,-1%
python -c "import os; import runpy; os.chdir(r""%wdir%""); runpy.run_path(r""%pyfile%"")"
pause
Editing Windows registries is not worth it and not safe, use Map network drive and load the network share as if it's loaded from one of your local drives.