write Administrator batch
Moderator: DosItHelp
-
- Posts: 2
- Joined: 17 Dec 2012 18:32
write Administrator batch
I am writing a batch file. Is there code I can add to have It run as Administrator? I know If I right click I can click on "run as Administrator". I would like to give this to a newbee for computers and let them run It by clicking on It.
Re: write Administrator batch
Try this: it will create a folder called c:\windows\system32\test123 and then echo the folder name to the screen if it has admin permissions.
Your code replaces the code after the :start label.
It will still generate a UAC prompt to confirm you want to run the code.
Your code replaces the code after the :start label.
It will still generate a UAC prompt to confirm you want to run the code.
Code: Select all
@echo off
if "%~1"=="a" goto :start
:getfile
set "file=%temp%\%random%.file.vbs"
if exist "%file%" goto :getfile
>"%file%" echo Set UAC = CreateObject("Shell.Application")
>>"%file%" echo UAC.ShellExecute "%~f0", "a", "", "runas", 1
start "" "%file%"
goto :EOF
:start
md "%windir%\system32\test123"
cd "%windir%\system32\test123"
echo %cd%
cd..
rd "%windir%\system32\test123"
pause
-
- Posts: 2
- Joined: 17 Dec 2012 18:32
Re: write Administrator batch
What I wanted to sent It to someone who Is a normal user and let them run the batch file In Administrator. For example: If I write a batch file to change the user password (I know you can do that from Windows 7). You only can do that from Admin. So I want to change user In a batch file from a User to Admintrator?
-
- Posts: 233
- Joined: 21 Nov 2010 08:07
- Location: At My Computer
Re: write Administrator batch
Here u go..
:: Disable
net user administrator /active:no
:: Or with WMIC
wmic useraccount where name='administrator' set disabled='false'
:: Disable
wmic useraccount where name='administrator' set disabled='true'

Code: Select all
@echo off
:: Enable Hidden Administrator Account
net user administrator /active:yes
:: Disable
net user administrator /active:no
:: Or with WMIC
wmic useraccount where name='administrator' set disabled='false'
:: Disable
wmic useraccount where name='administrator' set disabled='true'