Windows 7 Forums

Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.


Windows 7: How do I make this Batch run as Administrator by default?

04 Nov 2015   #21
Vilpo

WIN 7 Ultimate x32
 
 

Quote   Quote: Originally Posted by dav1129 View Post
Quote   Quote: Originally Posted by hugo1111 View Post
Hi mate,

your batch file is fantastic and is exactly the work around i was looking for. However, it fails to reset the current date automatically upon leaving and prompts me to enter it manually ...any idea Why ? i ve copied and pasted your code and saved it as a batch file. I am running XP 32, so i don t have any run as administrator option, although logged on as one.

thanks for your help
were you addressing me? if so, I started the thread because I needn't help myself. This is all a little beyond me although I did ultimately, get batch file together which worked. Trouble is I deleted the program because I want to upgrade it and never did. I'll see if I can find the batch file.......

Code:
ECHO OFF
CLS
:MENU
ECHO.
ECHO ....................................... ........
ECHO PRESS 1 to select your task, or 2 to EXIT.
ECHO ....................................... ........
ECHO.
ECHO 1 - Launch C:\ETKA\PROG1\Etka7.exe "C:\ETKA\PROG\ETKA_VW.INI"
ECHO 2 - Exit
ECHO.
SET /P M=Type 1, 2, then press ENTER:
IF %M%==1 GOTO PROGRAM
IF %M%==2 GOTO RESETDATE

:PROGRAM
FOR /F "TOKENS=1* DELIMS= " %%A IN ('DATE/T') DO SET CURDATE=%DATE%
COLOR 4f
echo Setting System date to 01-01-2012
echo.
date 01-01-2012
echo Launching Program........Please Wait
echo.
START /W C:\ETKA\PROG1\Etka7.exe "C:\ETKA\PROG\ETKA_VW.INI"
echo Resetting System Date back to Todays Date....Please Wait

date %CURDATE%
This batch file above worked for me. It reset the system date (to earlier one, which allowed my program to run without recent updates), and then start the program. The DOS command window stays open and when the desired program was closed, reset the system date.

I am not sure any more how I got this to work for me but if it works for you, great. Of course, you will have to swap the executable. If it doesn't work as is, you'll have to try some trial and error and learn a little DOS yourself.
I was looking for a way to run ETKA too, without needing to update it every time. So i found this writeup, it was very helpful. Thanks dav1129.
But, as Hugo1111 stated earlier, i was not able to get it return the original date back after shutting down ETKA.
So i started tinkering with the batch file, and i noticed that the %CURDATE% variable has the date with weekday in front, like this: "ke 4.11.2015".
So i edited the batch to remove the first three characters and now it works for me at least. I'm on windows 7 32-bit.
Here is what i did:
Code:
ECHO OFF
CLS
:MENU
ECHO.
ECHO ....................................... ........
ECHO PRESS 1 to select your task, or 2 to EXIT.
ECHO ....................................... ........
ECHO.
ECHO 1 - Launch E:\ETKA\VWAU\PROG1\Etka7.exe "E:\ETKA\VWAU\PROG\ETKA_VW.INI"
ECHO 2 - Exit
ECHO.
SET /P M=Type 1, 2, then press ENTER:
IF %M%==1 GOTO PROGRAM
IF %M%==2 GOTO RESETDATE

:PROGRAM
FOR /F "TOKENS=1* DELIMS= " %%A IN ('DATE/T') DO SET CURDATE=%DATE%
SET CLEANDATE=%CURDATE:* =%
COLOR 4f
echo Setting System date to 01-06-2015
echo.
date 01-06-2015
echo Launching Program........Please Wait
echo.

START /W E:\ETKA\VWAU\PROG1\Etka7.exe "E:\ETKA\VWAU\PROG\ETKA_VW.INI"
echo Resetting System Date back to Todays Date....Please Wait

date %CLEANDATE%
I also changed the paths, since i have ETKA 7.5. And date doesn't need to be set back so much (1.6.2015).


My System SpecsSystem Spec
.
Reply

 How do I make this Batch run as Administrator by default?




Thread Tools Search this Thread
Search this Thread:

Advanced Search




Similar help and support threads
Thread Forum
How to run a batch , .bat, flle as administrator
I run a batch file from the Windows scheduler and get an error 5, 'access denied'. If i run the batch file as administrator I have access and everything is OK except I must answer the UAC popup. The question is "How can I run the batch file from the scheduler with admin privileges and NOT have to...
General Discussion
Execute Program in Batch File As Administrator (Or Other Solution)
We use a program called TFC.exe (Temp File Cleaner - addpcs.com) to wipe all sorts of temp files off a computer on a monthly basis. The older version was a standalone .exe that users used to execute from a a folder on a server. The newer version is actually installed on each user's PC. If...
General Discussion
shutdown in batch file requires Administrator
Hi all, I've been using GFI Backup 2009 for backups for a while, it does everything I want, and sends email reports after backup is complete. One of its features is to shutdown the computer after a backup, this rarley works, as it wont shutdown if a program is already running, including GFI...
General Discussion
Batch File on USB fails when Ran As Administrator
I am new to this site so please excuse any lack of etiquette I may show. I have recently built a .bat files to perform a large number of configuration changes needed for a Win7 or Win8 workstation to function properly on my network. The .bat file obviously needs to be ran with elevated...
Software
How to always run batch file as administrator?
I've made a batch file, but i don't know how to make it to always run as administartor. In .bat's file properties the option "always run as administartor" is grayed out. I have to right click it and then choose "run as administartor" from context menu. But i don't want to do it every time because...
General Discussion
batch files - run as administrator
I am a software developer (dot net). Until recently I did all my work in the XP environment. I developed a utility library that goes into the global assembly cache. In the XP world this was easy. I write some .bat files that called the gacutil.exe and passed it the appropriate parameters. ...
General Discussion


Our Sites

Site Links

About Us

Find Us

Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd

All times are GMT -5. The time now is 14:49.

Twitter Facebook Google+



Windows 7 Forums

Seven Forums Android App Seven Forums IOS App