Solved

Windows Server 2008 - CMD and bat file access is denied

Posted on 2014-09-15
4
1,663 Views
Last Modified: 2014-09-15
Hello Experts Exchange
I have a windows server 2008 machine and I'm trying to run a batch file with logging in it, but every time I run the file I get Access is Denied.  I can run other Bat files and they work OK, I think it error at the point it creates a new log file.

Here is the code.
@echo off
setlocal

@REM *** START: Turns logging on ***
if "%~1" == "NOWLOGGING" goto NowLogging
    set SchedulesLogFile=%~n0 - %date:/=-% %time::=_%.txt
    set SchedulesLogFile=%~n0 - %RANDOM%.txt
    set SchedulesLogFile=%~n0.txt
    %0 "NOWLOGGING" > "%SchedulesLogFile%" 2>&1
    goto :EOF
:NowLogging
@REM *** END: Turns logging on ***


@rem Guts of batch file...
echo [%date% %time%] starting...
echo *** start of actual batch file...
...
echo *** end of actual batch file...
echo [%date% %time%] ending...

Open in new window


How do I resolve the problem?

Regards

SQLSearcher
0
Comment
Question by:SQLSearcher
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 4

Expert Comment

by:Neeraj Kumar
ID: 40322841
You might don't have permission from the drive from where you running the command.

Check the NTFS permission
0
 
LVL 23

Expert Comment

by:rhandels
ID: 40322854
Maybe i'm misinterpreting the script, but what folder are you placing the file in??
Better yet, what drive. I only see that the files name should be date/time but there doesn't seem to be a folder.
What if you try to add c:\temp for example??
0
 
LVL 12

Expert Comment

by:trinitrotoluene
ID: 40322875
A couple of things you can try :
- create a folder and move the batch file there and then try running it from there.

- Modify your script to create a log file in a folder where you have write permissions. Hardcode the path to it in your script or get it as user input
0
 
LVL 14

Accepted Solution

by:
Ben Hart earned 500 total points
ID: 40323051
What type of user are you logging into the server with and what rights does it have on the system, local admin?  Are you running the batch file from the user accounts startup folder?

Can you login to the server, browse to where this batch file is stored and double-click to run it manually successfully?
0

Featured Post

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Resolve DNS query failed errors for Exchange
The recent Microsoft changes on update philosophy for Windows pre-10 and their impact on existing WSUS implementations.
This tutorial will give a short introduction and overview of Backup Exec 2012 and how to navigate and perform basic functions. Click on the Backup Exec button in the upper left corner. From here, are global settings for the application such as conne…
This tutorial will show how to configure a single USB drive with a separate folder for each day of the week. This will allow each of the backups to be kept separate preventing the previous day’s backup from being overwritten. The USB drive must be s…

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question