|
Answer» in windows 10...
Code: [Select]echo off cd c:\ REN 1.hlp 1.txt pause When executed returns - access is denied, Press any key to continue. Why? How to fix?
both the batch file and 1.hlp file are in c:\Root directory protections. If you place those into a directory within C: such as at C:\Data it will likely work flawless. Everything you got going on should really be elsewhere but root of C: unless it absolutely needs to happen in root of C:
I think only way to get around the access denied in root of C: is to open the command shell as ADMINISTRATOR which should shut off the access denied issue as its a protection put in place by Microsoft to stop malicious changes from root of C:It does seem to be a privilege issue, but merely adding a new directory in C does not fix it. in other words...
Code: [Select]echo off cd c:\TEST pause ren 1.hlp 1.txt does not work for me(BAT file and 1.hlp moved to c:\test) by changing the permission of the shortcut to "run as admin" results in a prompt to proceed and then it does run. I will try this with the full batchfile and report back.Hi You should run your batch as administrator to achieve your aim, so try like that instead :
Code: [Select]echo off Title Renaming file If [%1] NEQ [Admin] Goto RunAsAdmin :MainScript cd c:\ ren 1.hlp 1.txt pause Exit ::--------------------------------------------------------------------------------------------------- :RunAsAdmin cls & color 0B & Mode 90,5 echo( echo( =========================================================== echo( Please wait a while ... Running as Admin .... echo( =========================================================== Powershell start -verb runas '%0' Admin & Exit ::---------------------------------------------------------------------------------------------------sounds good....will do this! I'm all good. things are working well. Had to work my way thru all the IF statements that are needed to make sure some unforeseen fault did not occur such as duplicate files, WRONG file with wrong name...etc.
thanks
|