we are using Windows Server 2008 R2 O/S. We want to execute an script that stops sql server 2008 in the night time (Around 3 am) and copy all the data files.
We want this process to be automatically done, as at 3 am no body would be available to run the batch file as an Administrator.
We've tried using the vbs script on the following link BatchGetAdmin Script
But no success.
We have also tried using runas command, but it is asking for the password, which to us is useless.
How do we achieve this simple task? any ideas?
Here is the script that we are trying to execute but it says "Access denied"
@echo off
:: BatchGotAdmin
:-------------------------------------
REM --> Check for permissions
>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"
REM --> If error flag set, we do not have admin.
if '%errorlevel%' NEQ '0' (
echo Requesting administrative privileges...
goto UACPrompt
) else ( goto gotAdmin )
:UACPrompt
echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
echo UAC.ShellExecute "%~s0", "", "", "runas", 1 >> "%temp%\getadmin.vbs"
"%temp%\getadmin.vbs"
exit /B
:gotAdmin
if exist "%temp%\getadmin.vbs" ( del "%temp%\getadmin.vbs" )
pushd "%CD%"
CD /D "%~dp0"
:--------------------------------------
net stop SERVER08
net stop SQLEXPRESS
net stop MSOLAP
net stop SQLBrowser
net stop MsDtsServer100
net stop ReportServer
net stop SQLWriter
net stop MSSQLFDLauncher