?
Solved

Windows Server 2008 - CMD and bat file access is denied

Posted on 2014-09-15
4
Medium Priority
?
1,721 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 2000 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

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

OfficeMate Freezes on login or does not load after login credentials are input.
The recent Microsoft changes on update philosophy for Windows pre-10 and their impact on existing WSUS implementations.
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles to another domain controller. Log onto the new domain controller with a user account t…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Suggested Courses

770 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