Bosland Posted July 9, 2010 Share Posted July 9, 2010 Hello,I have a script that disables the LAN/WLAN and then start an app to connect to UMTS/3G.If i close de app the connections will be enabled again, but when i shutdown, restart or log off in windows the script stops and the LAN/WLAN stay disabled.Does somebody have a solution for this?Gr. BoslandShortcut for app is a batch file;@echo off@clsecho.echo UMTS launcher...echo.runasspc /cryptfile:"disable.spc" /quiet (Runas as admin devcon tool to disable lan/wlan!!)start HPCM.lnkping localhost -n 3 >nulstart processwaiter.exeProceswaiter.exe (created whit Autoit);AutoItSetOption("TrayIconHide", 1)ProcessWaitClose("gbxapp.exe")Run("runasspc /cryptfile:enable.spc /quiet") Link to comment Share on other sites More sharing options...
JadeGolem Posted July 9, 2010 Share Posted July 9, 2010 (edited) I assume you're running in windows? Couldn't you put a batch file that runs runasspc /cryptfile:enable.spc /quiet in your startup folder? Edited July 9, 2010 by JadeGolem Link to comment Share on other sites More sharing options...
KaFu Posted July 9, 2010 Share Posted July 9, 2010 (edited) Code below tells windows 1) to give the program priority in the shutdown queue and 2) receives a Windows message on shutdown, which gives you ~5 seconds (on Vista and Win7, I think on XP you can even abort the shutdown) to gracefully end your program (__ExitFunction()). expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> GUICreate("My GUI") GUISetState(@SW_SHOW) #region ; This function sets a shutdown order for a process relative to the other processes in the system. ; http://msdn.microsoft.com/en-us/library/ms686227%28VS.85%29.aspx #cs 000-0FF = System reserved last shutdown range. 100-1FF = Application reserved last shutdown range. 200-2FF = Application reserved "in between" shutdown range. 300-3FF = Application reserved first shutdown range. 400-4FF = System reserved first shutdown range. #ce Global Const $SHUTDOWN_NORETRY = 0x00000001 DllCall("kernel32.dll", "BOOL", "SetProcessShutdownParameters", "DWORD", 0x3FF, "DWORD", $SHUTDOWN_NORETRY) #endregion ; This function sets a shutdown order for a process relative to the other processes in the system. #region ; The WM_QUERYENDSESSION message is sent when the user chooses to end the session or when an application calls one of the system shutdown functions ; http://msdn.microsoft.com/en-us/library/aa376890%28v=VS.85%29.aspx Global $WM_QUERYENDSESSION = 0x0011 GUIRegisterMsg($WM_QUERYENDSESSION, "WM_QUERYENDSESSION") #endregion ; The WM_QUERYENDSESSION message is sent when the user chooses to end the session or when an application calls one of the system shutdown functions While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop WEnd GUIDelete() Func WM_QUERYENDSESSION($hWnd, $msg, $wParam, $lParam) Local Const $ENDSESSION_CLOSEAPP = 0x00000001 ;ENDSESSION_CLOSEAPP ;The application is using a file that must be replaced, the system is being ;serviced, or system resources are exhausted. For more information, see Guidelines ;for Applications. Local Const $ENDSESSION_CRITICAL = 0x40000000 ;ENDSESSION_CRITICAL ;The application is forced to shut down. Local Const $ENDSESSION_LOGOFF = 0x80000000 ;ENDSESSION_LOGOFF ;The user is logging off. For more information, see Logging Off. Switch $lParam Case $ENDSESSION_CLOSEAPP ; MsgBox(0, "MSG", "ENDSESSION_CLOSEAPP") Case $ENDSESSION_CRITICAL ; MsgBox(0, "MSG", "ENDSESSION_CRITICAL") Case $ENDSESSION_LOGOFF ; MsgBox(0, "MSG", "ENDSESSION_LOGOFF") EndSwitch __ExitFunction() Return $GUI_RUNDEFMSG EndFunc ;==>WM_QUERYENDSESSION Func __ExitFunction() Exit EndFunc ;==>__ExitFunction Edit: Meaning, in the _Exit function you can reenable the LAN connection... Edited July 9, 2010 by KaFu  OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2022-Nov-26) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Feb-16) HMW - Hide my Windows (2018-Sep-16) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2023-Jun-03) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
Bosland Posted July 9, 2010 Author Share Posted July 9, 2010 I assume you're running in windows? Couldn't you put a batch file that runs runasspc /cryptfile:enable.spc /quiet in your startup folder? The problem is that if another user want to log on, the lan is disabled... so that's not a solution Link to comment Share on other sites More sharing options...
Bosland Posted July 9, 2010 Author Share Posted July 9, 2010 Code below tells windows 1) to give the program priority in the shutdown queue and 2) receives a Windows message on shutdown, which gives you ~5 seconds (on Vista and Win7, I think on XP you can even abort the shutdown) to gracefully end your program (__ExitFunction()). expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> GUICreate("My GUI") GUISetState(@SW_SHOW) #region ; This function sets a shutdown order for a process relative to the other processes in the system. ; http://msdn.microsoft.com/en-us/library/ms686227%28VS.85%29.aspx #cs 000-0FF = System reserved last shutdown range. 100-1FF = Application reserved last shutdown range. 200-2FF = Application reserved "in between" shutdown range. 300-3FF = Application reserved first shutdown range. 400-4FF = System reserved first shutdown range. #ce Global Const $SHUTDOWN_NORETRY = 0x00000001 DllCall("kernel32.dll", "BOOL", "SetProcessShutdownParameters", "DWORD", 0x3FF, "DWORD", $SHUTDOWN_NORETRY) #endregion ; This function sets a shutdown order for a process relative to the other processes in the system. #region ; The WM_QUERYENDSESSION message is sent when the user chooses to end the session or when an application calls one of the system shutdown functions ; http://msdn.microsoft.com/en-us/library/aa376890%28v=VS.85%29.aspx Global $WM_QUERYENDSESSION = 0x0011 GUIRegisterMsg($WM_QUERYENDSESSION, "WM_QUERYENDSESSION") #endregion ; The WM_QUERYENDSESSION message is sent when the user chooses to end the session or when an application calls one of the system shutdown functions While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop WEnd GUIDelete() Func WM_QUERYENDSESSION($hWnd, $msg, $wParam, $lParam) Local Const $ENDSESSION_CLOSEAPP = 0x00000001 ;ENDSESSION_CLOSEAPP ;The application is using a file that must be replaced, the system is being ;serviced, or system resources are exhausted. For more information, see Guidelines ;for Applications. Local Const $ENDSESSION_CRITICAL = 0x40000000 ;ENDSESSION_CRITICAL ;The application is forced to shut down. Local Const $ENDSESSION_LOGOFF = 0x80000000 ;ENDSESSION_LOGOFF ;The user is logging off. For more information, see Logging Off. Switch $lParam Case $ENDSESSION_CLOSEAPP ; MsgBox(0, "MSG", "ENDSESSION_CLOSEAPP") Case $ENDSESSION_CRITICAL ; MsgBox(0, "MSG", "ENDSESSION_CRITICAL") Case $ENDSESSION_LOGOFF ; MsgBox(0, "MSG", "ENDSESSION_LOGOFF") EndSwitch __ExitFunction() Return $GUI_RUNDEFMSG EndFunc ;==>WM_QUERYENDSESSION Func __ExitFunction() Exit EndFunc ;==>__ExitFunction Edit: Meaning, in the _Exit function you can reenable the LAN connection... I tried but get an error from Windows; Can't initialize ..... Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now