Solved

Windows Server 2008 - CMD and bat file access is denied

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

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

Suggested Solutions

A safe way to clean winsxs folder from your windows server 2008 R2 editions
This article explains how to install and use the NTBackup utility that comes with Windows Server.
This tutorial will walk an individual through the steps necessary to install and configure the Windows Server Backup Utility. Directly connect an external storage device such as a USB drive, or CD\DVD burner: If the device is a USB drive, ensure i…
This tutorial will walk an individual through the process of installing the necessary services and then configuring a Windows Server 2012 system as an iSCSI target. To install the necessary roles, go to Server Manager, and select Add Roles and Featu…

685 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