sites.google.com Open in urlscan Pro
2a00:1450:4001:82a::200e  Public Scan

URL: https://sites.google.com/site/eneerge/scripts/batchgotadmin
Submission: On September 03 via api from US

Form analysis 1 forms found in the DOM

/site/eneerge/system/app/pages/search

<form id="sites-searchbox-form" action="/site/eneerge/system/app/pages/search" role="search"><input type="hidden" id="sites-searchbox-scope" name="scope" value="search-site"><input type="text" id="jot-ui-searchInput" name="q" size="20" value=""
    aria-label="Search this site">
  <div id="sites-searchbox-button-set" class="goog-inline-block">
    <div role="button" id="sites-searchbox-search-button" class="goog-inline-block jfk-button jfk-button-standard" tabindex="0" style="user-select: none;">Search this site</div>
  </div>
</form>

Text Content

Search this site

NAVIGATION

 * 
   Home (RSS)
   * A-DATA Nobility Hard Drive Review
   * Automatic Updating Fresh Install Kit
   * DELL Unveils "Secure Browser"
   * Firefox Addon to Protect You From Bad Websites
   * How to Make CCleaner Clean All Accounts on the Fly
   * Introducing: FolderSpan
   * Launch
   * Launch Batch Scripts as Administrator (with GUI UAC prompt)
   * Securing Your Browser on Windows XP
   * Untitled Post
   * VMWare ThinApp - Building, Installing, and Using the Perfect Firefox
     ThinApp
   * Windows Vista SP2 Updated Image Using vLite and WPI
 * About Me
 * Links
 * 
   Malware Info
   * 1. Prevention
   * 2. Detection
   * 3. Removal Tools
   * Removal Guide #1
   * Removal Guide #2
 * 
   Projects
   * EZ DISM
   * FolderSpan
   * QB QuickItem
 * 
   Reviews
   * A-DATA Nobility
 * 
   Scripts
   * BatchGotAdmin
   * E-Tweaks 2.0
   * E-Tweaks XP
   * Imaging Scripts
   * mIRC Scripts
 * Videos
 * WPC54GV2 Hack
 * Sitemap





Scripts‎ > ‎


BATCHGOTADMIN

UPDATE 12/12/2011: Updated with some better code, thanks to Aaron Thoma
UPDATE 11/16/2011: I received some feedback from an international user who had
issues using this script when special characters were included in the file
name.  I've implemented some changes to fix these issues.

Finally got a batch script to prompt for administrator privileges in a GUI.


This will automatically elevate a .CMD or .BAT batch file using the standard UAC
prompt.




Just put this at the top of your batch script.

BatchGotAdmin International-Fix Code:


@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"
:--------------------------------------



<YOUR BATCH SCRIPT HERE>




BatchGotAdmin Original Code:
@echo off


:: Get ADMIN Privs
:-------------------------------------
mkdir "%windir%\BatchGotAdmin"
if '%errorlevel%' == '0' (
  rmdir "%windir%\BatchGotAdmin" & goto gotAdmin 
) else ( goto UACPrompt )


:UACPrompt
    echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
    echo UAC.ShellExecute %0, "", "", "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"
:-------------------------------------
:: End Get ADMIN Privs


<YOUR BATCH SCRIPT HERE>


Basically this just creates a VBS Script on the fly and invokes the batch script
using it.  It checks to see if the current window is running as administrator by
attempting to create a folder that requires administrative access.  If the
directory can not be created, then it invokes the UAC dialog, then closes the
non-admin window.  The script can also be executed from an already open
administrative CLI.

Comments
Anonymous
undefined
 
Your @mention will add people to this discussion and send an email.
Making sure people you mentioned have access…
The assigned person will be notified and responsible for marking as done.



Cancel
You do not have permission to add comments.
Evan Greene
 
Nov 20, 2011
•
Comments off
•
Re-open
From Aaron
----------

Hi, I hope this message reaches you. I didn\'t find a way to contact you on your
Google Site. :(

Thanks for your self-elevating script! Here\'s a tiny fix:
in the line
echo UAC.ShellExecute %0, \"\", \"\", \"runas\", 1 >> \"%temp%\\getadmin.vbs\"
replace %0 with %~s0
because with a special character in the path (German Umlaut \"ü\"), the VBS
interpreter didn\'t see it anymore. I guess
that\'s a bug on M$\'s part, so this is a workaround.
(Info on that syntax: http://www.computerhope.com/forhlp.htm#03
%~sI expanded path contains short names only)

I also suggest this shorter version of checking for elevation:
at >nul
if \'%errorlevel%\' == \'0\' (
because that saves purging the dummy dir.
Source: http://www.robvanderwoude.com/clevertricks.php
Reply


undefined
 
Your @mention will add people to this discussion and send an email.
Making sure people you mentioned have access…
The assigned person will be notified and responsible for marking as done.



Cancel





Sign in|Recent Site Activity|Report Abuse|Print Page|Powered By Google Sites




Link to this comment...

Done