Solved

Windows Server 2008 - CMD and bat file access is denied

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

The article will show you how you can maintain a simple logfile of all Startup and Shutdown events on Windows servers and desktops with PowerShell. The script can be easily adapted into doing more like gracefully silencing/updating your monitoring s…
The reason that corporations and businesses use Windows servers is because it supports custom modifications to adapt to the business and what it needs. Most individual users won’t need such powerful options. Here I’ll explain how you can enable Wind…
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 tutorial will walk an individual through the process of configuring their Windows Server 2012 domain controller to synchronize its time with a trusted, external resource. Use Google, Bing, or other preferred search engine to locate trusted NTP …

746 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now