Link to home
Start Free TrialLog in
Avatar of Nicky Raven
Nicky RavenFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Batch File Problems

Hello Everyone

I have recently updated my system to windows 10 from windows 7 and the following batch file i have to launch active directory and the lik on my system is no longer working as it comes up with the following. I had ran the command prompt as my ad min user and this was also elevated so i believe its my code but i would like pointers or even an easier way to do this.

Thank you all in advance.

--------------------------------------------------------------
Enter the password for Company\Admin13:
Attempting to start "C:\Users\ME\Documents\Scripts\Toolbox.bat" /runas as user "Company\Admin13" ...
RUNAS ERROR: Unable to run - "C:\Users\ME\Documents\Scripts\Toolbox.bat" /runas
5: Access is denied.
--------------------------------------------------------------

hear is the batch file in all its glory

@echo off & setlocal enableDelayedExpansion

set /a size=80-1 & rem screen size minus one

if /i "%~1"=="/runas" goto Start
runas.exe /user:Company\Admin13 "\"%~f0\" /runas"
goto :eof
:Start

set s=Running as %UserDomain%\%Username%
for /L %%# in (1,2,!size!) do if "!s:~%size%,1!" == "" set "s= !s! "
set s=!s:~1,%size%!& echo(!s!

:echo.
:set s=================
:for /L %%# in (1,2,!size!) do if "!s:~%size%,1!" == "" set "s= !s! "
:set s=!s:~1,%size%!& echo(!s!

:set s=Active Directory 32-Bit
:for /L %%# in (1,2,!size!) do if "!s:~%size%,1!" == "" set "s= !s! "
:set s=!s:~1,%size%!& echo(!s!
:start "" "dsa.msc" -32

echo.
set s=================
for /L %%# in (1,2,!size!) do if "!s:~%size%,1!" == "" set "s= !s! "
set s=!s:~1,%size%!& echo(!s!

set s=Active Directory 64-bit
for /L %%# in (1,2,!size!) do if "!s:~%size%,1!" == "" set "s= !s! "
set s=!s:~1,%size%!& echo(!s!
start "" "dsa.msc"

echo.
set s==========================
for /L %%# in (1,2,!size!) do if "!s:~%size%,1!" == "" set "s= !s! "
set s=!s:~1,%size%!& echo(!s!

set s=Microsoft Exchange Console
for /L %%# in (1,2,!size!) do if "!s:~%size%,1!" == "" set "s= !s! "
set s=!s:~1,%size%!& echo(!s!
start "" "Exchange Management Console.msc"

echo.
set s=============================
for /L %%# in (1,2,!size!) do if "!s:~%size%,1!" == "" set "s= !s! "
set s=!s:~1,%size%!& echo(!s!

set s=Windows Server Update Service
for /L %%# in (1,2,!size!) do if "!s:~%size%,1!" == "" set "s= !s! "
set s=!s:~1,%size%!& echo(!s!
start "" "C:\Program Files\Update Services\administrationsnapin\wsus.msc"

echo.
set s=========================
for /L %%# in (1,2,!size!) do if "!s:~%size%,1!" == "" set "s= !s! "
set s=!s:~1,%size%!& echo(!s!

set s=Windows Printer Managment
for /L %%# in (1,2,!size!) do if "!s:~%size%,1!" == "" set "s= !s! "
set s=!s:~1,%size%!& echo(!s!
start "" "printmanagement.msc"

echo.
set s=====================
for /L %%# in (1,2,!size!) do if "!s:~%size%,1!" == "" set "s= !s! "
set s=!s:~1,%size%!& echo(!s!

set s=system Lockout Status
for /L %%# in (1,2,!size!) do if "!s:~%size%,1!" == "" set "s= !s! "
set s=!s:~1,%size%!& echo(!s!
start "" "C:\Program Files (x86)\Windows Resource Kits\Tools\lockoutstatus.exe"

:echo =======================
:echo Terminal Services Admin
:start "" "tsadmin.msc"
:echo.
:echo =======================
:echo Lazy Windows Admin (PS)
:start "" "C:\Users\ME\Documents\scripts\Lazy Win Admin.lnk"

pause

Open in new window

Avatar of Michael Pfister
Michael Pfister
Flag of Germany image

Make sure the admin user has at least read permissions on the Batch E\Documents\Scripts\Toolbox.bat
Avatar of Nicky Raven

ASKER

My Admin User is in the administrator group so has access to the full drive
On the Windows 7 machine, have you disabled UAC ?
ASKER CERTIFIED SOLUTION
Avatar of Lee W, MVP
Lee W, MVP
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
@John. The UAC is not disabled on the domain for both windows 7 and windows 10 systems.

@Lee W. I have tried this and come up with the same error

this is probably an egocentricity of windows 10 and will have to find another way of getting around this.
Does it work when you manually use "run as" on any Windows exe or your batch?


If not you might have this problem: https://support.microsoft.com/en-us/help/977513/error-message-when-you-try-to-use-the-runas-command-the-run-as-adminis

Different OS but worth to check....
@ Michael. this did work with my admin account but not my main account.

i have found out that security replication  had not taken place fully on my laptop so my account and my admin account did not have full access to each others area and thus its what Lee W stated permissions even though i had checked this...... I hate windows on the best of days.

thanks all for you posts and information