Jump to content











Photo
- - - - -

Bug in ShutdownPE Script


  • Please log in to reply
10 replies to this topic

#1 doveman

doveman

    Frequent Member

  • Advanced user
  • 449 posts
  • Location:Surrey
  •  
    United Kingdom

Posted 16 March 2012 - 02:09 AM

The error is "IniRead - Failed to find file: [%BaseDir%\Target\Win7PE_SE\Windows\system32\ShutdownPE_lng.ini]" but taking a quick look at the script, it deliberately deletes this file if the language is English

Configuring language options...
IF - [%sb_lang%] is not equal to: [english] evaluated string: [If,%SB_Lang%,Equal,"English",Begin]
[// we want english so delete any language file]
[If,ExistFile,"%target_win%\system32\ShutdownPE_lng.ini",FileDelete,"%target_win%\system32\ShutdownPE_lng.ini"]

#2 homes32

homes32

    Gold Member

  • .script developer
  • 1035 posts
  • Location:Minnesota
  •  
    United States

Posted 22 March 2012 - 08:40 PM

The error is "IniRead - Failed to find file: [%BaseDir%TargetWin7PE_SEWindowssystem32ShutdownPE_lng.ini]" but taking a quick look at the script, it deliberately deletes this file if the language is English

Configuring language options...
IF - [%sb_lang%] is not equal to: [english] evaluated string: [If,%SB_Lang%,Equal,"English",Begin]
[// we want english so delete any language file]
[If,ExistFile,"%target_win%system32ShutdownPE_lng.ini",FileDelete,"%target_win%system32ShutdownPE_lng.ini"]


that fact that the language scrollbox is returning a value of %sb_lang% is not correct.
I have only seen this issue with winbuilder if the scrollbox is set to a NULL (empty) value.
did you modify the script?
you can try to select a different language in the script interface and then set it back to english. otherwise re-download the script.
  • doveman likes this

#3 doveman

doveman

    Frequent Member

  • Advanced user
  • 449 posts
  • Location:Surrey
  •  
    United Kingdom

Posted 22 March 2012 - 08:53 PM

Thanks. I hadn't modifed it and it was on English, but changing it to French and back to English seems to have fixed it :)

#4 Rocken

Rocken
  • Members
  • 5 posts
  •  
    Australia

Posted 12 October 2013 - 08:19 PM

I have a similar issue and it only occurs when trying to save a pre-shutdown command.  It is some sort of interface bug. It seems to be a design issue in that you must manually SAVE that settings page.

 

Here is a fix for the issue:

History15a=Small code optimization with extract.
History16=Call,AddInterface following macro library
History17=Rocken, Fix for the assumption in History16 that user left the interface in the [Interface] state and not the [Interface-Advanced]
 
[variables]
%ProgramTitle%=ShutdownPE
%ProgramEXE%=ShutdownPE.exe
%ProgramFolder%=%target_sys%
// do not change this var. it will be configured based on this scripts language option
%ShortcutName%=Shutdown
//History17 - Added
%InterfaceCurrent%=Interface
 
[process]
If,%version%,Smaller,80,Begin
// See this post for details on this requirement: http://www.boot-land.net/forums/index.php?showtopic=10349
Echo,"Winbuilder 080 or higher is required in order for this script to configure advanced options. Build will continue as normal but ShutdownPE.ini will not be created.",WARN
End
// we need to add Advanced interface variables for the script to see
//History17 - History16 MADE ASSUMPTION USER HAS LEFT THE INTERFACE ON THE DEFAULT:[Interface]
//History17 - History17 Makes the assumption that the script functioning correctly is more important than user forgetfullness
//History17 - START - This fix allows user to BE ON EITHER interface.
IniRead,%ScriptFile%,Main,Interface,%InterfaceCurrent%
If,%InterfaceCurrent%,Equal,"Interface",Call,AddInterface,%scriptfile%,Interface-Advanced,
If,%InterfaceCurrent%,Equal,"Interface-Advanced",Call,AddInterface,%scriptfile%,Interface,
//History17 - END
RunFromRam,True


#5 Rocken

Rocken
  • Members
  • 5 posts
  •  
    Australia

Posted 12 October 2013 - 08:36 PM

Hi There Developer of ShutdownPE.exe:

 

In addition to above fix for interface bug please also note this bug caused a number of issues and revealed a key weakness in the ShutdownPE.exe.

 

The EXE can be called multiple times at shutdown and this causes a lot of problems when it has hooked the shutdown request as you end up with multiple instances that are unaware of each other.  Especially when it executes other (potentially flawed) pre-shutdown code.

 

Your ShutdownPE.exe code needs to become "Self-Aware" and if it has hung before it should default to Killing any previous processes of same name and then shutting down WITHOUT calling the shutdown commands again and again.  Maybe an option to do so 2 or N tries before an unmitigated shutdown. It should be a priority that you shutdown/restart the PC as the user has requested, as they may be doing so remotely and have as a consequence lost their remote control session to sort this issue out.  I had to basically resort to a physical switch off to get around this while debugging the above issue.  I was emulating remote control sessions and this issues would have caused a site visit or intervention had it been deployed.

 

As the program stands it is a hard choice between using its benefits and putting up with its issues and requirrment for rock-solid testing without a graceful back out.

 

Thanks. Rocken



#6 homes32

homes32

    Gold Member

  • .script developer
  • 1035 posts
  • Location:Minnesota
  •  
    United States

Posted 16 October 2013 - 08:00 PM

I have a similar issue and it only occurs when trying to save a pre-shutdown command. It is some sort of interface bug. It seems to be a design issue in that you must manually SAVE that settings page.

yep. one of the quirks of the multi-interface features of winbuilder. your solution seems reasonable, I'll include it in the next official release.

 

The EXE can be called multiple times at shutdown and this causes a lot of problems when it has hooked the shutdown request as you end up with multiple instances that are unaware of each other.  Especially when it executes other (potentially flawed) pre-shutdown code.


should be an easy fix to add a mutex and restrict ShutdownPE to a single instance.
in regard to buggy programs being called by ShutdownPE and not terminating correctly I could be possible to add a "timeout" period where if an external app was called and exceeded the timeout period ShutdownPE would prompt to terminate the pre-shutdown program or continue to wait another timeout cycle.

regards,
Homes32

#7 Rocken

Rocken
  • Members
  • 5 posts
  •  
    Australia

Posted 16 October 2013 - 09:24 PM

yep. one of the quirks of the multi-interface features of winbuilder. your solution seems reasonable, I'll include it in the next official release.

 

should be an easy fix to add a mutex and restrict ShutdownPE to a single instance.
in regard to buggy programs being called by ShutdownPE and not terminating correctly I could be possible to add a "timeout" period where if an external app was called and exceeded the timeout period ShutdownPE would prompt to terminate the pre-shutdown program or continue to wait another timeout cycle.

regards,
Homes32

 

 

Thanks for your attention.

 

I have since realised the script would be better modified in this way as it would support more interfaces without retrofit.  Not that it is essential but just a better way for learners interface scripting to not get caught out.

History16=Call,AddInterface following macro library
History17=Rocken, Fix for the assumption in History16 that user left the interface in the [Interface] state and not the [Interface-Advanced]

[variables]
%ProgramTitle%=ShutdownPE
%ProgramEXE%=ShutdownPE.exe
%ProgramFolder%=%target_sys%
// do not change this var. it will be configured based on this scripts language option
%ShortcutName%=Shutdown
//History17 - Added
%InterfaceCurrent%=Interface

[process]
If,%version%,Smaller,80,Begin
// See this post for details on this requirement: http://www.boot-land...showtopic=10349
Echo,"Winbuilder 080 or higher is required in order for this script to configure advanced options. Build will continue as normal but ShutdownPE.ini will not be created.",WARN
End
// we need to add Advanced interface variables for the script to see
//History17 - History16 MADE ASSUMPTION USER HAS LEFT THE INTERFACE ON THE DEFAULT:[Interface]
//History17 - History17 Makes the assumption that the script functioning correctly is more important than user forgetfullness
//History17 - START - This fix allows user to BE ON EITHER interface.
IniRead,%ScriptFile%,Main,Interface,%InterfaceCurrent%
If,%InterfaceCurrent%,Not Equal,"Interface-Advanced",Call,AddInterface,%scriptfile%,Interface-Advanced,
If,%InterfaceCurrent%,Not Equal,"Interface",Call,AddInterface,%scriptfile%,Interface,
//History17 - END
RunFromRam,True

 

But I am also left wondering if this much simpler approach would work and may have been as intended by designer(s) (HOWEVER THIS HAS NOT BEEN TESTED):
 
History16=Call,AddInterface following macro library
History17=Rocken, Fix for the assumption in History16 that user left the interface in the [Interface] state and not the [Interface-Advanced]

[variables]
%ProgramTitle%=ShutdownPE
%ProgramEXE%=ShutdownPE.exe
%ProgramFolder%=%target_sys%
// do not change this var. it will be configured based on this scripts language option
%ShortcutName%=Shutdown

[process]
If,%version%,Smaller,80,Begin
// See this post for details on this requirement: http://www.boot-land...showtopic=10349
Echo,"Winbuilder 080 or higher is required in order for this script to configure advanced options. Build will continue as normal but ShutdownPE.ini will not be created.",WARN
End
// we need to add Advanced interface variables for the script to see
//History17 - History16 MADE ASSUMPTION USER HAS LEFT THE INTERFACE ON THE DEFAULT:[Interface]
//History17 - History17 Makes the assumption that the script functioning correctly is more important than user forgetfullness
//History17 - START - This fix allows user to BE ON EITHER interface.
AddInterface,%scriptfile%,Interface-Advanced,
AddInterface,%scriptfile%,Interface,
//History17 - END
RunFromRam,True

Thanks, Rocken.



#8 Rocken

Rocken
  • Members
  • 5 posts
  •  
    Australia

Posted 16 October 2013 - 09:29 PM

Feature Request:  It would also be nice if you could relocate (offset from center) or set a screen corner or top or bottom center as locations for the ShutdownPE GUI as when running commands on restart/shutdown youre GUI gets in the way of programs GUI that you cannot control (easily).

 

Thanks Again, Rod,



#9 homes32

homes32

    Gold Member

  • .script developer
  • 1035 posts
  • Location:Minnesota
  •  
    United States

Posted 17 October 2013 - 01:37 PM

[process]
If,%version%,Smaller,80,Begin
// See this post for details on this requirement: http://www.boot-land...showtopic=10349
Echo,"Winbuilder 080 or higher is required in order for this script to configure advanced options. Build will continue as normal but ShutdownPE.ini will not be created.",WARN
End
// we need to add Advanced interface variables for the script to see
//History17 - History16 MADE ASSUMPTION USER HAS LEFT THE INTERFACE ON THE DEFAULT:[Interface]
//History17 - History17 Makes the assumption that the script functioning correctly is more important than user forgetfullness
//History17 - START - This fix allows user to BE ON EITHER interface.
AddInterface,%scriptfile%,Interface-Advanced,
AddInterface,%scriptfile%,Interface,
//History17 - END
RunFromRam,True

This is a good question for Psc to answer if using this approach would cause issues for winbuilder.

In theory it should work as the command just reads the ini values of the section into the scripts memory but i do not know if winbuilder loads the current interface as const in which case it would obviously fail.

 

Edit: quickly tested and winbuilder did not throw an error adding both interfaces.



#10 ChrisR

ChrisR

    Silver Member

  • .script developer
  • 784 posts
  •  
    France

Posted 17 October 2013 - 08:21 PM

Hi Homes32,

 

I had the same concern, there is a while now in Explorer shell of Win7PE SE.
It was resolved in exactly the same way. With additional quotes, it does not seem required, but the last comma, yes.

AddInterface,%scriptfile%,Interface-Advanced,""
AddInterface,%scriptfile%,Interface,""

Otherwise, as you are in shutdownPE, There is a problem with the Hook dll In Win8PE. If you can take a look
SPEHook.dll works fine with the reboot option (Windows Default integration or Open ShutdownPE GUI)
but it doesn't work, it doesn't call ShutdownPE for the Shudown option.

Your script in Win8PE_SE is without the shell integration for this reason,

 

Maybe related,

 

With windows 8, ExitWindowsEx can set a new flag called EWX_HYBRID_SHUTDOWN.
For info, the updated JFX's Reboot.dll hook files in Win8pese explorer shell works fine.

 

You can use them with the old AppInit_DLLs method:

 

[HKEY_LOCAL_MACHINE\PE-SOFTWARE\Microsoft\Windows NT\CurrentVersion\Windows]
"AppInit_DLLs"="ReBoot.dll"
"LoadAppInit_DLLs"=dword:00000001
"RequireSignedAppInit_DLLs"=dword:00000000



#11 homes32

homes32

    Gold Member

  • .script developer
  • 1035 posts
  • Location:Minnesota
  •  
    United States

Posted 19 October 2013 - 02:09 AM

Hi Chris. Good to see you around. I have fixed the windows 8 shutdown in the latest test version.  I should hopefully have a beta available early next week as I am on vacation this weekend and still want to clean up a bit of code before release.
Cheers!
Homes32






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users