Access denied when trying to copy file Windows Vista - security

I have this batch that needs to run that the user has to execute that will copy a simple xml file. However, everything works fine on windows 2000/XP. However, on windows Vista I get an error 'Access Denied".
Even when I try and copy the file just using windows explorer on Vista I get the same error.
Is there anything I can do to make this file copy. Do I have to add any extra code to my bat file to enable copying of this file?
Many thanks.
#ECHO OFF
REM copy config file to the windows/system32
copy config.xml c:\windows\system32\DataLinks.xml

I'm guessing it's because you're trying to change windows\system32. Vista, 7 and future version of Windows require elevated privileges in order to change system32.
Do you really need to put this file in system32? If it's an arbitrary location, why not pop it in the user's AppData directory (%AppData%\DataLinks.xml)?
AppData is a standard directory that's been around since Windows 2000 that hides in the user's Documents and Settings or Users folder (depending on the version). It's a hidden but user-editable folder, intended for application settings that the user needs to be able to get to but is mostly only going to be used by your code.

You need elevated privs to copy to %windir%\system32
You shouldn't copy your config data into %windir% at all. That's for Windows. Use %AppData%.
If you do copy to %windir%, use the %windir% variable and don't hardcode the path C:\Windows

JS Bangs is right; use %windir% variable. Most of the time when you do that it won't give any errors.
Example:
#ECHO OFF
REM copy config file to the windows/system32
copy config.xml %windir%\system32\DataLinks.xml
But while would you? Just put it in any other one. Like AppData what was already said:
#ECHO OFF
REM copy config file to the windows/system32
copy config.xml %appdata%\DataLinks.xml

Related

windows 10 - permission denied when trying to delete folder

I have a certain folder on my computer that I want to delete but I can't. I opened the cmd console as administrator and tried to delete the folder, but access was denied. It doesn't even let me change ownership on the folder. I'm using windows 10 64-bit. How can I delete the folder?
Thanks.
Try Lock Hunter , its a unlocker software which worked well for me
open power shell as administrator
cd c:\folderInQuestion
rm -r .\folderInQuestion\
If the folder lies outide of your specific User Account folder, then you will have to take ownership of the folder (or a parent folder) before you can delete it.
In my case, I needed to delete a subfolder that was nested deep inside my Projects folder, which sits at my root. Even though my account had "full control" (see this)
To take ownership of the folder, follow this: https://answers.microsoft.com/en-us/windows/forum/windows_10-files/give-permissions-to-files-and-folders-in-windows/78ee562c-a21f-4a32-8691-73aac1415373

Installing GLPK

I'm following this link for installing GLPK which I intend to use to conduct some optimization. When I've downloaded GLPK, and added
C:\Windows\System32 and C:\Windows\SysWOW64
to PATH for environment variables and try to execute one of the example files (even by opening the cmd window in the file where the test file is located) by doing
glpsol --model assign.mod
It says that
glpsol is not a internal command, external command, program or command file.
When I open the command in the win64 folder (a subfolder of glpk) then I can do:
glpsol.exe --help
and get information. I can also see the glpsol programfile in the folder. However when I try to open a model somewhere on my computer it does'nt recognize glpsol. Isn't that why you add System32 into your PATH?
In the guide it says that
...Therefore it is suggested to copy the DLLs to %SystemRoot%nsystem32.
Is this something that you must do? Which are these DLLs? Can you do this using a command in the cmd file? I thinking that including System32 into the path does this?
I've added SysWOW64 into the path due to me using 64 Bit Windows 7. Not sure if it is the way to go though.
Hope someone can shed some light into this!
Regards,
To use glpsol outside of the dedicated folder you have to put the relevant files somewhere, where your System can recognize them (somewhere in the defined Path Environment)
The "DLLs" are just the glpk_X_XX.dll, for 64bit systems use the dll in the w64 folder and put it in the SysWOW64. Now your System will find the dll - but still not glpsol. Just copy the glpsol.exe in system32 for that, and voilĂ  your done.
Adding the GLPK Directory to the Environment Path should also work.

phpstorm write issues in ./idea directory

When I try to save a file to disc within a project directory, I get this error:
java.io.IOException: W:\\[projectname]\\.idea not found
Some research tells me, the (network) location is not writable.
I'm trying to write this file from phpstorm in windows 8.
The drive (W:) is a network drive to a linux machine.
The directory I try to write to is chowned to the same user and group as I connect with in windows.
This is a result of ls -alh:
drwxrwxrwx 2 correct-user correct-user
On Linux and other Unix-like operating systems files starting with a . are considered 'hidden files' by default. As such, when the Windows-based program creates it, it suddenly doesn't see it anymore right after since it's hidden, even though the creation was successful. You can fix this in your Samba config by adding the following line to the share configuration:
hide dot files = no
In my samba settings I added a veto files parameter. Removing this parameter allows me to write dot files again.
Samba describes this setting as follows:
This is a list of files and directories that are neither visible nor accessible

Where's the "TEMP" folder for Custom Build Steps?

Visual Studio 2010, in my project I made a custom build step which renames a dll file and copies it to other folder. So, Alt+F7, Config props, Custom Build Step / General, command line:
copy /y $(TargetPath) $(TargetName).node
It didn't do anything. Then I also added
ping bat.femei.ro -n 1 -w 5000
It still didn't do anything. It simply flashed a command prompt window for a split second then the window went away. I googled as much as I could concluding that there might be a problem with the folder where the batch file is generated.
I did my best to screenshot that split second with the command prompt and after a boring F7-PrintScreen-PasteInPaint session finally I got
C:\Users\FURAT\AppData\Local\Temp\blablablablablablablablabla.exec.cmd is not recognized as internal or external...
I double checked the directory. It has Everyone permissions set to Allow both Read & Write operations. What's wrong? How do I fix this?
I was unable to find any knobs to tweak temp folder path. It's not Env and it's not in the config either.
What did work however was running VS2010 as Administrator. Now the Custom Build Step works.

SVN Error (Can't set file)

Everytime I try to commit files to SVN I got the following error.
Command Commit
Modified D:\Project\src\WebSite\SomePage.aspx.cs
Sending Content D:\Project\AKent\src\WebSite\Test\SomePage.aspx.cs
Commit succeeded, but other errors follow:
Error bumping revisions post-commit (details follow):
Can't set file 'D:\Project\AKent\src\WebSite\Test\SomePage.aspx.cs'
read-write: Access is denied.
After I get this error, SVN doesnt allow me to update or commit anything! And what is really frustrating me is that the project folder is around 2 GB and every night I download it from SVN over and over.
Please help me to fix it! I just wanna know what is wrong with my SVN. I tried reinstalling, didn't fix anything.
I had the same problem but fixed. My solution is:
1. Run Command Prompt as Administrator
2. Navigate to the target working copy
3. svn cleanup
The error
read-write: Access is denied.
indicates that svn can not access the file or can't set all attributes it needs to that file.
Now that either means you have not full access to those files or some other application has the file opened exclusively.
In the first case: make sure that your username has full access to all folders and subfolders of your working copy. Note that on Vista/Win7 it's not enough to be an admin - you have to give yourself full access to such files manually.k
In the second case: disable windows search indexer for your working copy, and exclude the working copy from being scanned by your virus scanner.
If you are sharing a svn versioned folder using samba and running into this issue when acessing it from windows machine, try:
http://tortoisesvn.net/faq.html#samba
Also add to your smb.conf file:
dos filemode = yes
copy the wrong folder (1) to another folder(2)
delete the wrong folder (1)
copy the backup(2) to (1)
Hope this approach works for you too!
I was trying to revert a file but was receiving the error listed in the OP's post. Soony's answer just about worked for me. I cannot comment or edit that answer, so I had to copy their answer and add a small step at the end. S/he deserves all the credit.
Run Command Prompt as Administrator
Navigate to the target working
copy svn cleanup
svn revert [filename]
(the revert did not work in Windows Explorer/TortoiseSVN integrated tools, I had to do it from the cmd line)

Resources