|
![]() |
Overclock.net - Overclocking.net > Software, Programming and Coding > Operating Systems > Windows | |
Running .bat with adminsitrative privaledges
|
||
![]() |
|
|
LinkBack | Thread Tools |
|
|
#1 (permalink) | |||||||||||||
|
Commodore 64
|
Recently, I have begun learning about writing simple scripts for common tasks and saving them as batch files. I have very limited experience and have encountered several issues.
1. The script "shutdown .bat" is simple enough, a timed shutdown. " shutdown /s /t 60". I have UAC disabled, so all cmd prompts are elevated. When I manually enter it @ the prompt it works flawlessly. However when I save it as .bat , create a shortcut pointing to is on the desktop and run it from there it goes bonkers: it opens the command prompt at the desktop user level, and endlessly prints the script at C: i.e. c:\"compname"\"user": shutdown \s \t 60 c:\"compname"\"user": shutdown \s \t 60 c:\"compname"\"user": shutdown \s \t 60 c:\"compname"\"user": shutdown \s \t 60 c:\"compname"\"user": shutdown \s \t 60 I have to break the operation to get it stop 2. As a result, I am pretty sure I have this running constantly in the background as if I run a different test script using the same technique... it still repeats the previous script over and over and over So after reading a bunch on the net that hasnt worked at all... I was hoping for some guidance here. Goals: execute the three following bat from desktop shortcut "restart.bat" - shutdown /r "shutdown.bat" - shutdown /s /t 60 "shutdowncancel.bat" - shutdown /a Also I would like to know how to break the failed script - much thanks from a newb
__________________
HOLY CRAP!!!
![]() Its my first build/mod log... ***DELIDDING: A HOW NOT TO*** ***DELIDDING pt2: A How to after how not to-ing*** pɐǝɥ ǝɥʇ uı ʎʞuoʍ sı ɹǝǝuoıd ...ʇsɐısnɥʇuǝ 939 ʇǝʞɔos
|
|||||||||||||
|
|
|
|
#2 (permalink) | |||||||||||||
|
4.0ghz
|
Don't you have to add some type of stop command a line below the shutdown request?
~Gooda~
__________________
Havegooda on OCN and [H]
|
|||||||||||||
|
|
|
|
#3 (permalink) | ||||||||||||||
|
Networking Nut
|
Quote:
![]() and what does the *.bat script look like? is there only this exactly as it is in it? Code:
shutdown /s /t 60 ![]() and when playing with shutdown scripts, always remeber shutdown /a cancels the scheduled shutdown ![]() and little tips for making scripts; adding a @ at the beginning of a line hides the path and command in the CMD, but thows the message of the command, and with & you can make multiple commands on one line, for example you can make Code:
cls ipconfig /all pause exit Code:
cls&ipconfig /all&pause&exit
__________________
|
||||||||||||||
|
|
|
|
#4 (permalink) | |||||||||||||
|
Commodore 64
|
@microX...
still a no go... and the script is exactly as you have reproduced it above. perhaps it is an issue exclusive the 64bit flavor... where security is tighter??? see attached pic
__________________
HOLY CRAP!!!
![]() Its my first build/mod log... ***DELIDDING: A HOW NOT TO*** ***DELIDDING pt2: A How to after how not to-ing*** pɐǝɥ ǝɥʇ uı ʎʞuoʍ sı ɹǝǝuoıd ...ʇsɐısnɥʇuǝ 939 ʇǝʞɔos
|
|||||||||||||
|
|
|
|
#5 (permalink) | ||||||||||||||
|
Networking Nut
|
Quote:
![]() you can always replace the command that opens the script with the commands from the script.. eg: a.bat: Code:
echo testas pause b.bat pause exit Code:
echo shutting down shutdown /S /T 60 Code:
echo testas pause echo shutting down shutdown /S /T 60 pause exit ![]() oh.. and i noticed theres a $ in the path.. special marks like that are known to cause troubles sometimes, sp you can try to run it from a different folder also ![]()
__________________
Last edited by Microx256 : 03-13-08 at 04:10 PM. |
||||||||||||||
|
|
|
|
#6 (permalink) | |||||||||||||
|
Commodore 64
|
the window behinds it is simply a cmd prompt I opened to demonstrate that the "cmd" command defaults to adminstrator priv.
the dollar sign is simply the user folder name... but I try running it from the base directory edit: unfortunately changing the origin directory (folder) does not solve the problem. It simply enters the non-terminating loop. Yet it runs perfectly if I open a command prompt and manually enter the script ???
__________________
HOLY CRAP!!!
![]() Its my first build/mod log... ***DELIDDING: A HOW NOT TO*** ***DELIDDING pt2: A How to after how not to-ing*** pɐǝɥ ǝɥʇ uı ʎʞuoʍ sı ɹǝǝuoıd ...ʇsɐısnɥʇuǝ 939 ʇǝʞɔos
Last edited by Poser : 03-13-08 at 04:58 PM. |
|||||||||||||
|
|
|
|
#7 (permalink) | |||||||||||||
|
Commodore 64
|
shamless bump...
should a mod move this to coding (though it is simple scripting... so probably not)
__________________
HOLY CRAP!!!
![]() Its my first build/mod log... ***DELIDDING: A HOW NOT TO*** ***DELIDDING pt2: A How to after how not to-ing*** pɐǝɥ ǝɥʇ uı ʎʞuoʍ sı ɹǝǝuoıd ...ʇsɐısnɥʇuǝ 939 ʇǝʞɔos
|
|||||||||||||
|
|
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
|
|