03 Oct 2010 @ 12:08 AM 

Executing batch files in UAC enabled Windows Vista/7 is a pain when the batch file is gonna make any changes to the restricted folders like windows or system32. UAC will just block any attempts to create or modify files from the protected folders. Hopefully there is an option to execute it with admin privileges by right clicking on bat file and selecting “Run as administrator”. This creates little trouble with current path. If bat is executed normally, it’s current path is the folder where bat resides, but if it is “Run as administrator” current path becomes \windows\system32. This will become a problem if we are trying to access a file which resides in the same folder as bat file. This problem can be resolved pretty easily by enabling command extensions and setting current path using %~dp0.

@setlocal enableextensions
@cd /d "%~dp0"

Posted By: Dan
Last Edit: 05 Oct 2010 @ 05:24 PM

EmailPermalink
Tags
Categories: Batch File, UAC


 

Responses to this post » (One Total)

 
  1. Adrian says:

    Thank you for the tip.Just what you need to deploy something on a Windows 7 client system

Post a Comment

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>


 Last 50 Posts
Change Theme...
  • Users » 1
  • Posts/Pages » 19
  • Comments » 41
Change Theme...
  • VoidVoid « Default
  • LifeLife
  • EarthEarth
  • WindWind
  • WaterWater
  • FireFire
  • LightLight

About



    No Child Pages.