• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Cannot run elevated shortcut from html


rdwray

Member
Member
Posts
301
#1
I have a gadget that has buttons for hibernate and standby to run a shortcut. If I run the short cut directly by clicking it, it works, but if I try to run it from the html button, it will not acknowledge the run as administrator setting. I have tried it with VBScript and cannot change the powercfg - h state.

Here is the html:
HTML:
<a id="hibernate"  onMouseOver='ShowTip(1,"Hibernate");' onMouseOut='HideTip(1);' href="../core/Hibernate.lnk" >
     <img src="../images/Hibernate.png" border="0" width="20" height="20" >
     <span id='tooltip1' class='tooltip'></span>
</a>
Here is the shortcut:
Code:
C:\Windows\System32\cmd.exe /c powercfg -h on & rundll32.exe powrprof.dll,SetSuspendState 0,1,0
Here is the VBScript:
Code:
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "%COMSPEC% /c POWERCFG /Hibernate ON"
WshShell.Run "rundll32.exe PowrProf.dll SetSuspendState Hibernate"
 

My Computer

System One

  • OS
    Windows 8 Pro
    System Manufacturer/Model
    Dell Inspiron 1750
    CPU
    Duo Core 2.5 G HZ

broe23

Retired from the grind
VIP Member
Pro User
Central IL

Posts
3,468
#2
You are really going about it the hard way. Why reinvent the wheel. If you are just going to use Metro/Start, use Ctrl-Alt-Del, to pull up the Start Button. If using 8.1.1, it is already on the Metro/start screen. If always using the desktop, use Classic Shell or Start8 from Stardock.com
 

My Computer

System One

  • OS
    Linux Mint 17.2
    Computer type
    Laptop
    System Manufacturer/Model
    Toshiba Satellite C850D-st3nx1
    CPU
    AMD E1-1200 APU with Radeon (tm) HD Graphics 1.40 GHZ
    Memory
    12GB
    Graphics Card(s)
    AMD Radeon™ HD 7310 Graphics
    Sound Card
    Realtek HD
    Monitor(s) Displays
    LCD
    Screen Resolution
    1366 x 768
    Hard Drives
    Crucial M500 240GB SSD
    Mouse
    Logitech M525
    Internet Speed
    45/6 - ATT U-Verse
    Browser
    Google Chrome
    Antivirus
    None needed. It is Linux.
    Other Info
    Arris NVG589 Gateway; Router - Cisco RV320; Switch - Netgear GS108 8-Port Switch & Trendnet TEG-S50g 5-Port Switch; Access Points - Engenius ECB350, Trendnet TEW-638APB; NAS - Lenovo ix2-4; Printer - Brother HL-2280DW; Air Print Server - Lantronix XPrintServer

    A/V UPS - Tripp-Lite Smart 1500LCD 1500 Va/900 W.

rdwray

Member
Member
Posts
301
#3
I have ClassicShell installed and I bypass all Windows 8 functionality - this is a laptop, not an android phone.:)
 

My Computer

System One

  • OS
    Windows 8 Pro
    System Manufacturer/Model
    Dell Inspiron 1750
    CPU
    Duo Core 2.5 G HZ

broe23

Retired from the grind
VIP Member
Pro User
Central IL

Posts
3,468
#4
We know that. Like I stated, if you are in Desktop mode, the classic Shut Down button is in the menu. If in Metro/Start on 8.1.1, the Shutdown icon is next to the picture. Why you are comparing Windows 8 to Android OS, makes no sense. One has nothing to do with the other.
 

My Computer

System One

  • OS
    Linux Mint 17.2
    Computer type
    Laptop
    System Manufacturer/Model
    Toshiba Satellite C850D-st3nx1
    CPU
    AMD E1-1200 APU with Radeon (tm) HD Graphics 1.40 GHZ
    Memory
    12GB
    Graphics Card(s)
    AMD Radeon™ HD 7310 Graphics
    Sound Card
    Realtek HD
    Monitor(s) Displays
    LCD
    Screen Resolution
    1366 x 768
    Hard Drives
    Crucial M500 240GB SSD
    Mouse
    Logitech M525
    Internet Speed
    45/6 - ATT U-Verse
    Browser
    Google Chrome
    Antivirus
    None needed. It is Linux.
    Other Info
    Arris NVG589 Gateway; Router - Cisco RV320; Switch - Netgear GS108 8-Port Switch & Trendnet TEG-S50g 5-Port Switch; Access Points - Engenius ECB350, Trendnet TEW-638APB; NAS - Lenovo ix2-4; Printer - Brother HL-2280DW; Air Print Server - Lantronix XPrintServer

    A/V UPS - Tripp-Lite Smart 1500LCD 1500 Va/900 W.

rdwray

Member
Member
Posts
301
#5
Metro/Start was designed for touch screens and to compete with google's android. Here is the final batch file I came up with that works and satisfies the issue; make sure that the last 9 lines are paid close attention to since this will work for hibernate and standby:
Code:
REM -- Minimize window --
if not "%minimized%"=="" goto :minimized
set minimized=true
start /min cmd /C "%~dpnx0"
goto :EOF
:minimized

REM -- Runs batch files as administrator --
REM --add the following to the top of your bat file --
@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"
    set params = %*:"=""
    echo UAC.ShellExecute "cmd.exe", "/c %~s0 %params%", "", "runas", 1 >> "%temp%\getadmin.vbs"

    "%temp%\getadmin.vbs"
    del "%temp%\getadmin.vbs"
    exit /B

:gotAdmin
    pushd "%CD%"
    CD /D "%~dp0"
    
REM -- Code you want to run --
:--------------------------------------
C:\Windows\System32\cmd.exe /c 
C:\Windows\system32\powercfg.exe -h on
rundll32.exe powrprof.dll,SetSuspendState 0,1,1

Rem The above 3 lines are for hibernate.
Rem The following 3 lines are for standby
Rem Use which ever is desired or create 2 batch files.

C:\Windows\System32\cmd.exe /c 
C:\Windows\system32\powercfg.exe -h off
rundll32.exe powrprof.dll,SetSuspendState 0,1,1
 

My Computer

System One

  • OS
    Windows 8 Pro
    System Manufacturer/Model
    Dell Inspiron 1750
    CPU
    Duo Core 2.5 G HZ

broe23

Retired from the grind
VIP Member
Pro User
Central IL

Posts
3,468
#6
There is no need to write a program to take the place of something else. The Windows Club forum has a Taskbar Shutdown/Logoff/Restart utility called "HotShut". Just download it, or like I stated before. The Metro/Start screen already has the icon next to the user login picture, if the computer is running 8.1.1. If in Desktop mode, again the Shutdown/Logoff/Restart is going to show up with either Classic Shell or Start8.

Also Windows 8 was never intended to compete against Android OS or iOS. Really wish you would get that out of your mind. Also yes it may be used for Touch screen interfaces to use the Metro Apps. They still work if you use a mouse.

You are overthinking something that all of the work has already been done.
 

My Computer

System One

  • OS
    Linux Mint 17.2
    Computer type
    Laptop
    System Manufacturer/Model
    Toshiba Satellite C850D-st3nx1
    CPU
    AMD E1-1200 APU with Radeon (tm) HD Graphics 1.40 GHZ
    Memory
    12GB
    Graphics Card(s)
    AMD Radeon™ HD 7310 Graphics
    Sound Card
    Realtek HD
    Monitor(s) Displays
    LCD
    Screen Resolution
    1366 x 768
    Hard Drives
    Crucial M500 240GB SSD
    Mouse
    Logitech M525
    Internet Speed
    45/6 - ATT U-Verse
    Browser
    Google Chrome
    Antivirus
    None needed. It is Linux.
    Other Info
    Arris NVG589 Gateway; Router - Cisco RV320; Switch - Netgear GS108 8-Port Switch & Trendnet TEG-S50g 5-Port Switch; Access Points - Engenius ECB350, Trendnet TEW-638APB; NAS - Lenovo ix2-4; Printer - Brother HL-2280DW; Air Print Server - Lantronix XPrintServer

    A/V UPS - Tripp-Lite Smart 1500LCD 1500 Va/900 W.

broe23

Retired from the grind
VIP Member
Pro User
Central IL

Posts
3,468
#7
Using the Powercfg /h off, disables Hibernate, it does not place the unit into hibernate mode.
 

My Computer

System One

  • OS
    Linux Mint 17.2
    Computer type
    Laptop
    System Manufacturer/Model
    Toshiba Satellite C850D-st3nx1
    CPU
    AMD E1-1200 APU with Radeon (tm) HD Graphics 1.40 GHZ
    Memory
    12GB
    Graphics Card(s)
    AMD Radeon™ HD 7310 Graphics
    Sound Card
    Realtek HD
    Monitor(s) Displays
    LCD
    Screen Resolution
    1366 x 768
    Hard Drives
    Crucial M500 240GB SSD
    Mouse
    Logitech M525
    Internet Speed
    45/6 - ATT U-Verse
    Browser
    Google Chrome
    Antivirus
    None needed. It is Linux.
    Other Info
    Arris NVG589 Gateway; Router - Cisco RV320; Switch - Netgear GS108 8-Port Switch & Trendnet TEG-S50g 5-Port Switch; Access Points - Engenius ECB350, Trendnet TEW-638APB; NAS - Lenovo ix2-4; Printer - Brother HL-2280DW; Air Print Server - Lantronix XPrintServer

    A/V UPS - Tripp-Lite Smart 1500LCD 1500 Va/900 W.

rdwray

Member
Member
Posts
301
#8
Powercfg /h off will put into Standby with: rundll32.exe powrprof.dll,SetSuspendState (not necessary to add Standby)
Powercfg /h on will put into Hibernate with: rundll32.exe powrprof.dll,SetSuspendState (not necessary to add Hibernate)

Give this a try:
Code:
' HIBERNATE.vbs
If WScript.Arguments.length =0 Then
    Set objShell = CreateObject("Shell.Application")
    objShell.ShellExecute "wscript.exe", Chr(34) & WScript.ScriptFullName & Chr(34) & " uac", "", "runas", 1
Else
    Set objShell = CreateObject("WScript.Shell")
    objShell.run "powercfg /hibernate on"
    objShell.run "rundll32.exe powrprof.dll,SetSuspendState"
End If

'STANDBY.vbs
If WScript.Arguments.length =0 Then
    Set objShell = CreateObject("Shell.Application")
    objShell.ShellExecute "wscript.exe", Chr(34) & WScript.ScriptFullName & Chr(34) & " uac", "", "runas", 1
Else
    Set objShell = CreateObject("WScript.Shell")
    objShell.run "powercfg /hibernate off"
    objShell.run "rundll32.exe powrprof.dll,SetSuspendState"
    WScript.Sleep 200
    objShell.run "powercfg /hibernate on"
End If
 

My Computer

System One

  • OS
    Windows 8 Pro
    System Manufacturer/Model
    Dell Inspiron 1750
    CPU
    Duo Core 2.5 G HZ

broe23

Retired from the grind
VIP Member
Pro User
Central IL

Posts
3,468
#9
Again it does not. That command disables the capability of Hibernate to be used on the machine. Stop trying to reinvent the wheel, when the work has already been done.
 

My Computer

System One

  • OS
    Linux Mint 17.2
    Computer type
    Laptop
    System Manufacturer/Model
    Toshiba Satellite C850D-st3nx1
    CPU
    AMD E1-1200 APU with Radeon (tm) HD Graphics 1.40 GHZ
    Memory
    12GB
    Graphics Card(s)
    AMD Radeon™ HD 7310 Graphics
    Sound Card
    Realtek HD
    Monitor(s) Displays
    LCD
    Screen Resolution
    1366 x 768
    Hard Drives
    Crucial M500 240GB SSD
    Mouse
    Logitech M525
    Internet Speed
    45/6 - ATT U-Verse
    Browser
    Google Chrome
    Antivirus
    None needed. It is Linux.
    Other Info
    Arris NVG589 Gateway; Router - Cisco RV320; Switch - Netgear GS108 8-Port Switch & Trendnet TEG-S50g 5-Port Switch; Access Points - Engenius ECB350, Trendnet TEW-638APB; NAS - Lenovo ix2-4; Printer - Brother HL-2280DW; Air Print Server - Lantronix XPrintServer

    A/V UPS - Tripp-Lite Smart 1500LCD 1500 Va/900 W.

rdwray

Member
Member
Posts
301
#10
You must understand that if I am not satisfied, I will pursue the matter to the end. I am now satisfied that this issue has been resolved and works. Here is the gadget that I wrote.

Capture.JPG
 

My Computer

System One

  • OS
    Windows 8 Pro
    System Manufacturer/Model
    Dell Inspiron 1750
    CPU
    Duo Core 2.5 G HZ

Ztruker

Well-Known Member
VIP Member
Guru
#11
Very cool. What does each button do? I see a Power Off and Lock, what about the other 3?
 

My Computer

System One

  • OS
    Windows 10 Pro X64
    Computer type
    PC/Desktop
    System Manufacturer/Model
    Lenovo IdeaCenter K450
    CPU
    Intel Quad Core i7-4770 @ 3.4Ghz
    Motherboard
    Lenovo
    Memory
    16.0GB PC3-12800 DDR3 SDRAM 1600 MHz
    Graphics Card(s)
    Intel Integrated HD Graphics
    Sound Card
    Realtek HD Audio
    Monitor(s) Displays
    HP h2207
    Screen Resolution
    [email protected]
    Hard Drives
    250GB Samsung EVO SATA-3 SSD;
    2TB Seagate ST2000DM001 SATA-2;
    1.5TB Seagate ST3150041AS SATA
    PSU
    500W
    Keyboard
    Wired USB
    Mouse
    Wired USB
    Internet Speed
    3GB Up, 30GB Down
    Browser
    SeaMonkey
    Antivirus
    Windows Defender; MBAM Pro
    Other Info
    UEFI/GPT
    PLDS DVD-RW DH16AERSH

rdwray

Member
Member
Posts
301
#12
There are tooltips that replace the "Select a button..."
Left to right: Standby; Shut Down; Restart; Logoff; Hibernate. Didn't see any need for Lock Screen.
 

My Computer

System One

  • OS
    Windows 8 Pro
    System Manufacturer/Model
    Dell Inspiron 1750
    CPU
    Duo Core 2.5 G HZ

Ztruker

Well-Known Member
VIP Member
Guru
#13
All in one, easy to access place, very nice.
 

My Computer

System One

  • OS
    Windows 10 Pro X64
    Computer type
    PC/Desktop
    System Manufacturer/Model
    Lenovo IdeaCenter K450
    CPU
    Intel Quad Core i7-4770 @ 3.4Ghz
    Motherboard
    Lenovo
    Memory
    16.0GB PC3-12800 DDR3 SDRAM 1600 MHz
    Graphics Card(s)
    Intel Integrated HD Graphics
    Sound Card
    Realtek HD Audio
    Monitor(s) Displays
    HP h2207
    Screen Resolution
    [email protected]
    Hard Drives
    250GB Samsung EVO SATA-3 SSD;
    2TB Seagate ST2000DM001 SATA-2;
    1.5TB Seagate ST3150041AS SATA
    PSU
    500W
    Keyboard
    Wired USB
    Mouse
    Wired USB
    Internet Speed
    3GB Up, 30GB Down
    Browser
    SeaMonkey
    Antivirus
    Windows Defender; MBAM Pro
    Other Info
    UEFI/GPT
    PLDS DVD-RW DH16AERSH

Users Who Are Viewing This Thread (Users: 0, Guests: 1)