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

EmailPermalinkComments (1)
Tags
Categories: Batch File, UAC

 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.