Solved

Windows Server 2008 - CMD and bat file access is denied

Posted on 2014-09-15
4
1,681 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

Free eBook: Backup on AWS

Everything you need to know about backup and disaster recovery with AWS, for FREE!

Question has a verified solution.

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

You might have come across a situation when you have Exchange 2013 server in two different sites (Production and DR). After adding the Database copy in ECP console it displays Database copy status unknown for the DR exchange server. Issue is strange…
While rebooting windows server 2003 server , it's showing "active directory rebuilding indices please wait" at startup. It took a little while for this process to complete and once we logged on not all the services were started so another reboot is …
This tutorial will show how to configure a new Backup Exec 2012 server and move an existing database to that server with the use of the BEUtility. Install Backup Exec 2012 on the new server and apply all of the latest hotfixes and service packs. The…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…

707 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