Jump to content

This site uses cookies. By continuing to browse the site you are agreeing to our use of cookies. Find out more here. X
X


Photo

Script running as service not spawning GUI


  • Please log in to reply
8 replies to this topic

#1 CGRemakes

CGRemakes

    Seeker

  • Active Members
  • 44 posts

Posted 24 May 2012 - 05:42 PM

I know doing a GUI from a service is not recommended and not possible in newer OSes. What I'm trying to do is spawn a subprocess as a different user to handle the GUI. It works great on XP, but never displays the GUI on W7. As far as I understand it, this should be possible. I'm using the service UDF from this thread: http://www.autoitscript.com/forum/topic/...-service-udf-v2-run-your-exe-a. This is a small portion of the code to show what I'm doing:

Func _CheckReboot() If $REQUIRE_REBOOT = True AND (Not $LAST_REBOOT_PAUSE_TIME OR _Timer_Diff($LAST_REBOOT_PAUSE_TIME) >= 3600000) Then   Local $msg = "An application installed and requires a reboot to complete."   Local $flag = 48   If $REBOOT_PAUSES_REMAINING > 0 Then    $msg &= " Reboot or pause (" & $REBOOT_PAUSES_REMAINING & " remaining)"    $flag = 49   EndIf   Local $iMsg = _MsgBoxEx($flag, 'System Reboot', $msg, 'Reboot|Pause', 300)   If $iMsg = 1 OR $iMsg = -1 Then  ;Either "Reboot" was clicked or timeout ran out, so reboot    Shutdown(22)   Else    $LAST_REBOOT_PAUSE_TIME = _Timer_Init()    $REBOOT_PAUSES_REMAINING -= 1   EndIf EndIf EndFunc Func _MsgBoxEx($iFlag, $sTitle, $sText, $sCIDChange, $iTimeout = 0) Return RunAsWait($USERNAME, @ComputerName, $PASSWORD, 1, @AutoItExe & ' /msgbox ' & $iFlag & ' "' & $sTitle & '" "' & $sText & '" "' & $sCIDChange & '" ' & $iTimeout, @ScriptDir, @SW_HIDE) EndFunc   ;==>_MsgBoxEx


Then in the portion where I handle command line switches, I have the following code:

Plain Text         
If $cmdline[0] > 0 Then Switch $cmdline[1]   Case "install", "-i", "/i" ;~  msgbox(0,"","toto")    InstallService()   Case "remove", "-u", "/u", "uninstall"    RemoveService()   Case "/download"    Exit _DownloadFilesCmd()   Case "/msgbox"    Exit _MsgBoxExCmd()   Case Else    ConsoleWrite(" - - - Help - - - " & @CRLF)    ConsoleWrite("params : " & @CRLF)    ConsoleWrite(" -i : install service" & @CRLF)    ConsoleWrite(" -u : remove service" & @CRLF)    ConsoleWrite(" - - - - - - - - " & @CRLF)    Exit    ;start service. EndSwitch Else _Service_init($sServiceName) Exit EndIf


The /msgbox flag calls the _MsgBoxExCmd() function, which is basically a MsgBox that displays and notifies them their computer will be rebooted. They have the option to reboot then or pause it. It will constantly refresh to show a countdown (code taken from Gary Frost I believe):

Plain Text         
Func _MsgBoxExCmd() Local $Static = "Static1" Local $iFlag = $CmdLine[2] Local $sTitle = $CmdLine[3] Local $sText = $CmdLine[4] Local $sCIDChange = StringSplit($CmdLine[5], "|") Local $iTimeout = $CmdLine[6] ;Local $sCIDChange[3] = ['', 'Reboot', 'Pause'] Local $_MsgBox_ If BitAND($iFlag, 16) Or BitAND($iFlag, 32) Or BitAND($iFlag, 48) Or BitAND($iFlag, 64) Then $Static = "Static2" If $iTimeout Then   $_MsgBox_ = '"' & "ConsoleWrite(MsgBox(" & $iFlag & ', ""' & $sTitle & '"", ""' & $sText & @LF & @LF & @LF & '"", ' & $iTimeout & '"))' Else   $_MsgBox_ = '"' & "ConsoleWrite(MsgBox(" & $iFlag & ', ""' & $sTitle & '"", ""' & $sText & '"", ' & $iTimeout & '"))' EndIf Local $iPID = Run(@AutoItExe & ' /AutoIt3ExecuteLine ' & $_MsgBox_, '', @SW_MAXIMIZE, 6) Do   Sleep(10) Until WinExists($sTitle) For $iCC = 1 To $sCIDChange[0]   ControlSetText($sTitle, '', 'Button' & $iCC, $sCIDChange[$iCC]) Next If $iTimeout Then _CountDown($sTitle, $sText, $iTimeout, $iPID, $Static) Local $iStdOut = StdoutRead($iPID) ; waiting... If Number($iStdOut) Then   $returncode = $iStdOut ElseIf IsArray($sCIDChange) Then   $returncode = 2 Else   $returncode = 1 EndIf Return $returncode EndFunc Func _CountDown($sTitle, $sText, $iTimeout, $iPID, $Static)     Local $orig_text = $sText, $now = -999, $now = @SEC     ControlSetText($sTitle, "", $Static, $orig_text & @LF & @LF & "This will automatically execute in " & $iTimeout & " second(s)!", 1) While Not Number(StdoutRead($iPID, 2, True))         If $now <> @SEC Then             $iTimeout -= 1             $now = @SEC             If $iTimeout Then ControlSetText($sTitle, "", $Static, $orig_text & @LF & @LF & "This will automatically execute in " & $iTimeout & " second(s)!", 1)   EndIf         Sleep(10)     WEnd EndFunc   ;==>_CountDown


If I just run the main program as either the current user or administrator on W7, it works as expected. However, when I run the program as a service, it never displays. It does reboot automatically after a set period of time (which is the correct behaviour if there is no interaction with the msgbox). I looked at the process list, and there are 2 sub processes spawned, both showing the user that I specified in $USERNAME in the _MsgBoxEx() function. Any thoughts?


Here is a functioning example. You will need to have the necessary service files from the first post of the service UDF thread, and you will need to change "$USERNAME" and "$PASSWORD" to something that will work on your system, but should be good to go.

Plain Text         
#NoTrayIcon #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Version=beta #AutoIt3Wrapper_Change2CUI=y #AutoIt3Wrapper_Res_requestedExecutionLevel=asInvoker #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** ;~ Opt("MustDeclareVars", 1) ; just for self control  FPRIVATE "TYPE=PICT;ALT=smile.gif" dont to forget declare vars Global $MainLog = @ScriptDir & "test_service.log" FileDelete($MainLog) Global $sServiceName = "Autoit_Service" Global $bServiceRunning = False, $iServiceCounter = 1 Global $hGUI Global $bDebug = False Dim $REQUIRE_REBOOT = True Dim $REBOOT_PAUSES_REMAINING = 3 Dim $LAST_REBOOT_PAUSE_TIME Dim $USERNAME = "username" Dim $PASSWORD = "password" #include "services.au3" #include <Timers.au3> ; i used it for timers func #include <File.au3> #include <Constants.au3> #include <Date.au3> #include <String.au3> #include <Array.au3> ; Thread safe ; Thread safe ;~ OnAutoItExitRegister("_exit") ; $bDebug = False Func main($iArg, $sArgs) #region -- STOP STOP STOP STOP - Don't change anything -- Service Start  ; Arcker 02/03/2012 If $bDebug Then logprint("***** & _Service_ServiceMain & *******" & @CRLF) $ret = DllCall($hAdvapi32_DLL, "hwnd", "RegisterServiceCtrlHandler", "ptr", DllStructGetPtr($tServiceName), "ptr", DllCallbackGetPtr($tServiceCtrl));register service If $ret[0] = 0 Then   logprint("Error in registering service" & _WinAPI_GetLastError_2())   _Service_ReportStatus($SERVICE_STOPPED, _WinAPI_GetLastError_2(), 0)   Return EndIf $tService_Status_handle = $ret[0] If Not ($tService_Status_handle) Then   _Service_ReportStatus($SERVICE_STOPPED, _WinAPI_GetLastError_2(), 0)   Return EndIf ;goto cleanup; DllStructSetData($tService_Status, "dwServiceType", $service_type) DllStructSetData($tService_Status, "dwServiceSpecificExitCode", 0); ; report the status to the service control manager. If Not (_Service_ReportStatus($SERVICE_START_PENDING, $NO_ERROR, 3000)) Then   ;goto cleanup;   _Service_ReportStatus($SERVICE_STOPPED, _WinAPI_GetLastError_2(), 0)   logprint("***** & error reporting Service_ReportStatus *******" & @CRLF)   _Service_Cleanup()   Return EndIf If Not _Service_ReportStatus($SERVICE_RUNNING, $NO_ERROR, 0) Then   logprint("Erreur sending running status, exiting")   _Service_ReportStatus($SERVICE_STOPPED, _WinAPI_GetLastError_2(), 0)   Return EndIf $bServiceRunning = True ; REQUIRED If $bDebug Then logprint("main start") #endregion -- STOP STOP STOP STOP - Don't change anything -- Service Start  ; Arcker 02/03/2012 Local $SUBMIT_LAST_REBOOT = True While $bServiceRunning ; REQUIRED  ( dont change variable name ) ; there are several ways to find that service have to be stoped - $Running flag in loop is the first method   #region --> insert your running code here   _CheckReboot()   Sleep(10000) #endregion --> insert your running code here WEnd #region -- service stopping _Service_ReportStatus($SERVICE_STOP_PENDING, $NO_ERROR, 1000); If $bDebug Then logprint("main stopped. Cleanup.") #region - STOP STOP STOP Service Stopped, don't change it or you will have stoping status _Service_ReportStatus($SERVICE_STOPPED, $NO_ERROR, 0) ; That all! Our AutoIt Service stops just there! 0 timeout meens "Now" ;~ Exit ;Bug here. In race conditions it's not executed. ProcessClose(@AutoItPID) Return #region - Service Stopped, don't change it or you will have stoping status EndFunc   ;==>main If $bDebug Then logprint("script started") If $cmdline[0] > 0 Then Switch $cmdline[1]   Case "install", "-i", "/i" ;~  msgbox(0,"","toto")    InstallService()   Case "remove", "-u", "/u", "uninstall"    RemoveService()   Case "/msgbox"    Exit _MsgBoxExCmd()   Case Else    ConsoleWrite(" - - - Help - - - " & @CRLF)    ConsoleWrite("params : " & @CRLF)    ConsoleWrite(" -i : install service" & @CRLF)    ConsoleWrite(" -u : remove service" & @CRLF)    ConsoleWrite(" - - - - - - - - " & @CRLF)    Exit    ;start service. EndSwitch Else _Service_init($sServiceName) Exit EndIf ; some loging func Func logprint($text, $nolog = 0) If $nolog Then   MsgBox(0, "MyService", $text, 1) Else   If Not FileExists($MainLog) Then FileWriteLine($MainLog, "Log created: " & @YEAR & "/" & @MON & "/" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC)   FileWriteLine($MainLog, @YEAR & @MON & @MDAY & " " & @HOUR & @MIN & @SEC & " [" & @AutoItPID & "] >> " & $text) EndIf Return 0 ;~ ConsoleWrite($text & @CRLF) EndFunc   ;==>logprint Func InstallService() Local $bDebug = True If $bDebug Then ConsoleWrite("InstallService(): Installing service, please wait") If $cmdline[0] > 1 Then   $sServiceName = $cmdline[2] EndIf _Service_Create($sServiceName, "Au3Service " & $sServiceName, BitOR($SERVICE_WIN32_OWN_PROCESS, $SERVICE_INTERACTIVE_PROCESS), $SERVICE_AUTO_START, $SERVICE_ERROR_SEVERE, '"' & @ScriptFullPath & '"') If @error Then   If $bDebug Then ConsoleWrite("InstallService(): Problem installing service, Error number is " & @error & @CRLF & " message : " & _WinAPI_GetLastErrorMessage()) Else   If $bDebug Then ConsoleWrite("InstallService(): Installation of service successful") EndIf Exit EndFunc   ;==>InstallService Func RemoveService() _Service_Stop($sServiceName) _Service_Delete($sServiceName) If Not @error Then   If $bDebug Then logprint("RemoveService(): service removed successfully" & @CRLF) EndIf Exit EndFunc   ;==>RemoveService Func _exit() ;~  if $bDebug  then logprint("Exiting") ; Clean opened dll ;~  DllClose($hKernel32_DLL) ;~  DllClose($hAdvapi32_DLL) _Service_ReportStatus($SERVICE_STOPPED, $NO_ERROR, 0); ;~ _service_cleanup("END") ;~ _Service_Cleanup("END") EndFunc   ;==>_exit #cs ...from MSDN: The ServiceMain function should perform the following tasks: Initialize all global variables. Call the RegisterServiceCtrlHandler function immediately to register a Handler function to handle control requests for the service. The return value of RegisterServiceCtrlHandler is a service status handle that will be used in calls to notify the SCM of the service status. Perform initialization. If the execution time of the initialization code is expected to be very short (less than one second), initialization can be performed directly in ServiceMain. If the initialization time is expected to be longer than one second, call the SetServiceStatus function, specifying the SERVICE_START_PENDING service state and a wait hint in the SERVICE_STATUS structure. If your service's initialization code performs tasks that are expected to take longer than the initial wait hint value, your code must call the SetServiceStatus function periodically (possibly with a revised wait hint) to indicate that progress is being made. Be sure to call SetServiceStatus only if the initialization is making progress. Otherwise, the Service Control Manager can wait for your service to enter the SERVICE_RUNNING state assuming that your service is making progress and block other services from starting. Do not call SetServiceStatus from a separate thread unless you are sure the thread performing the initialization is truly making progress. When initialization is complete, call SetServiceStatus to set the service state to SERVICE_RUNNING. Perform the service tasks, or, if there are no pending tasks, return control to the caller. Any change in the service state warrants a call to SetServiceStatus to report new status information. If an error occurs while the service is initializing or running, the service should call SetServiceStatus to set the service state to SERVICE_STOP_PENDING if cleanup will be lengthy. After cleanup is complete, call SetServiceStatus to set the service state to SERVICE_STOPPED from the last thread to terminate. Be sure to set the dwServiceSpecificExitCode and dwWin32ExitCode members of the SERVICE_STATUS structure to identify the error. #ce ; emulating your program init() function ;~ Func main_init() ;~  $hGUI = GUICreate("Timers Using CallBack Function(s)") ;~ GUISetState($hGUI,@SW_HIDE) ; unneeded - timers run exelent without guisetstate. ;~  $MainLog = @ScriptDir & "test_service.log" ;~  $sServiceName = "Autoit_Service" ;~  $Running = 1 ;~  if $bDebug  then logprint("main_init. Stop event=" & $service_stop_event) ;~ EndFunc   ;==>main_init ; stop timer function. its said SCM that service is in the process of $SERVICE_STOP_PENDING ;~ Func myStopTimer($hWnd, $Msg, $iIDTimer, $dwTime) ;~  if $bDebug  then logprint("timer = " & $counter) ;~  _Service_ReportStatus($SERVICE_STOP_PENDING, $NO_ERROR, $counter) ;~  $counter += -100 ;~ EndFunc   ;==>myStopTimer Func StopTimer() ;~  if $bDebug  then logprint("timer = " & $counter) _Service_ReportStatus($SERVICE_STOP_PENDING, $NO_ERROR, $iServiceCounter) $iServiceCounter += -100 EndFunc   ;==>StopTimer ; emulate your program main function with while loop (may be gui loop & so on) Func _Stopping() _Service_ReportStatus($SERVICE_STOP_PENDING, $NO_ERROR, 3000) EndFunc   ;==>_Stopping Func _CheckReboot() If $REQUIRE_REBOOT = True AND (Not $LAST_REBOOT_PAUSE_TIME OR _Timer_Diff($LAST_REBOOT_PAUSE_TIME) >= 3600000) Then   Local $msg = "An application installed and requires a reboot to complete."   Local $flag = 48   If $REBOOT_PAUSES_REMAINING > 0 Then    $msg &= " Reboot or pause (" & $REBOOT_PAUSES_REMAINING & " remaining)"    $flag = 49   EndIf   Local $iMsg = _MsgBoxEx($flag, 'System Reboot', $msg, 'Reboot|Pause', 300)   If $iMsg = 1 OR $iMsg = -1 Then  ;Either "Reboot" was clicked or timeout ran out, so reboot    Shutdown(22)   Else    $LAST_REBOOT_PAUSE_TIME = _Timer_Init()    $REBOOT_PAUSES_REMAINING -= 1   EndIf EndIf EndFunc Func _MsgBoxEx($iFlag, $sTitle, $sText, $sCIDChange, $iTimeout = 0) Return RunAsWait($USERNAME, @ComputerName, $PASSWORD, 1, @AutoItExe & ' /msgbox ' & $iFlag & ' "' & $sTitle & '" "' & $sText & '" "' & $sCIDChange & '" ' & $iTimeout, @ScriptDir, @SW_HIDE) EndFunc   ;==>_MsgBoxEx Func _MsgBoxExCmd() Local $Static = "Static1" Local $iFlag = $CmdLine[2] Local $sTitle = $CmdLine[3] Local $sText = $CmdLine[4] Local $sCIDChange = StringSplit($CmdLine[5], "|") Local $iTimeout = $CmdLine[6] ;Local $sCIDChange[3] = ['', 'Reboot', 'Pause'] Local $_MsgBox_ If BitAND($iFlag, 16) Or BitAND($iFlag, 32) Or BitAND($iFlag, 48) Or BitAND($iFlag, 64) Then $Static = "Static2" If $iTimeout Then   $_MsgBox_ = '"' & "ConsoleWrite(MsgBox(" & $iFlag & ', ""' & $sTitle & '"", ""' & $sText & @LF & @LF & @LF & '"", ' & $iTimeout & '"))' Else   $_MsgBox_ = '"' & "ConsoleWrite(MsgBox(" & $iFlag & ', ""' & $sTitle & '"", ""' & $sText & '"", ' & $iTimeout & '"))' EndIf Local $iPID = Run(@AutoItExe & ' /AutoIt3ExecuteLine ' & $_MsgBox_, '', @SW_MAXIMIZE, 6) Do   Sleep(10) Until WinExists($sTitle) For $iCC = 1 To $sCIDChange[0]   ControlSetText($sTitle, '', 'Button' & $iCC, $sCIDChange[$iCC]) Next If $iTimeout Then _CountDown($sTitle, $sText, $iTimeout, $iPID, $Static) Local $iStdOut = StdoutRead($iPID) ; waiting... If Number($iStdOut) Then   $returncode = $iStdOut ElseIf IsArray($sCIDChange) Then   $returncode = 2 Else   $returncode = 1 EndIf Return $returncode EndFunc Func _CountDown($sTitle, $sText, $iTimeout, $iPID, $Static)     Local $orig_text = $sText, $now = -999, $now = @SEC     ControlSetText($sTitle, "", $Static, $orig_text & @LF & @LF & "This will automatically execute in " & $iTimeout & " second(s)!", 1) While Not Number(StdoutRead($iPID, 2, True))         If $now <> @SEC Then             $iTimeout -= 1             $now = @SEC             If $iTimeout Then ControlSetText($sTitle, "", $Static, $orig_text & @LF & @LF & "This will automatically execute in " & $iTimeout & " second(s)!", 1)   EndIf         Sleep(10)     WEnd EndFunc   ;==>_CountDown

Edited by CGRemakes, 01 June 2012 - 02:01 PM.








#2 JLogan3o13

JLogan3o13

    115 and holding

  • MVPs
  • 4,327 posts

Posted 24 May 2012 - 07:19 PM

Hi, CGRemakes. I just quickly glanced through your posted scripts. When creating the service, are you selecting the option to allow it to interact with the local desktop? I created a service for a customer last year and ran into roughly the same issue you're describing when I neglected this option.

If you put a million monkeys on a million keyboards, one of them will eventually write a Java program. The rest of them will write Perl programs.

 

My Scripts: SCCM UDFInclude Source with Compiled Script, Disk Maintenance for Windows XP, "Deal-A-Day" Sites, Windows Firewall UDF


#3 CGRemakes

CGRemakes

    Seeker

  • Active Members
  • 44 posts

Posted 24 May 2012 - 07:42 PM

I've done it both ways with the same result: no interaction.

EDIT: Just a note, I changed the _Service_Create to this:

_Service_Create($sServiceName, "Au3Service " & $sServiceName, BitOR($SERVICE_WIN32_OWN_PROCESS, $SERVICE_INTERACTIVE_PROCESS), $SERVICE_AUTO_START, $SERVICE_ERROR_SEVERE, '"' & @ScriptFullPath & '"')

But still, no luck. Before, I was manually setting the "interact" flag to on, but now it should be created with it on. I can verify it's checked after it's created.

Edited by CGRemakes, 24 May 2012 - 10:36 PM.


#4 arcker

arcker

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 581 posts

Posted 25 May 2012 - 08:20 AM

check this key :
HKEY_LOCAL_MACHINESYSTEMCurrentControlSetControlWindows
Nointeractiveservice
it is set to 1 by default, set it to 0 and try

-- Arck System _ Soon -- Ideas make everything

"La critique est facile, l'art est difficile"

 

Projects :

  • Au3Service : Run your exe as service V3 / Updated 29/07/2013 Get it Here

#5 arcker

arcker

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 581 posts

Posted 25 May 2012 - 08:41 AM

if you only need a message box, then wtssendmessage is the most simple solution i think.

-- Arck System _ Soon -- Ideas make everything

"La critique est facile, l'art est difficile"

 

Projects :

  • Au3Service : Run your exe as service V3 / Updated 29/07/2013 Get it Here

#6 Tripredacus

Tripredacus

    K-Mart-ian Legend

  • Active Members
  • PipPipPipPipPipPip
  • 839 posts

Posted 25 May 2012 - 02:43 PM

What user account is the service running under? Some accounts are not allowed to interact with the desktop. One such example is Local Service.

#7 CGRemakes

CGRemakes

    Seeker

  • Active Members
  • 44 posts

Posted 25 May 2012 - 02:49 PM

The agent is running as the service account, but is spawning sub processes as a different user that has that ability.

#8 CGRemakes

CGRemakes

    Seeker

  • Active Members
  • 44 posts

Posted 25 May 2012 - 03:07 PM

if you only need a message box, then wtssendmessage is the most simple solution i think.


I did a search and found this post:

http://www.autoitscript.com/forum/topic/...-service-to-use-wtssendmessage

That solution works great to display the message. How would I dynamically update the count down message so they know when it's going to automatically perform the action? And is it possible to edit the text in the buttons? I want it to be more apparent that they are simply pausing the action. Yes, I could say "Click Cancel to pause", but I'd rather not if I can avoid it. I'd like to "stupid proof" it as much as possible.


EDIT: Nevermind, figured it out. I didn't know you could interact with that message box just like the MsgBox control.

EDIT EDIT: Still having some issues. It seems W7 is unable to change text or button information (even if I just run it as a regular user, it returns "0" when I run the ControlSetText command). It just sticks with whatever it was when it was created. Is there any other way to pull it off using wtssendmessage? That seems to be the way to go.

Edited by CGRemakes, 25 May 2012 - 10:45 PM.


#9 CGRemakes

CGRemakes

    Seeker

  • Active Members
  • 44 posts

Posted 30 May 2012 - 03:59 PM

Here is a very simple example of what I'm trying to do:

I have this code in 1 file:

#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Res_requestedExecutionLevel=asInvoker #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <WinAPI.au3> $ShutDownWindowTimeout=800 $UserActionMessage = "SHUTDOWN" $pTitle = DllStructCreate("char Title[32]") $pMessage = DllStructCreate("char Message[128]") $pResponse = DllStructCreate("DWORD Response") $KernelCall = DllOpen(@SystemDir & "Kernel32.dll") $SessionId = DllCall($KernelCall, "DWORD", "WTSGetActiveConsoleSessionId") DllClose($KernelCall) DllStructSetData($pTitle, "Title", "Scheduled Power Action") DllStructSetData($pMessage, "Message", "Your computer is scheduled to " & $UserActionMessage & ". Click CANCEL to keep working.") $wtsapiCall = DllOpen(@SystemDir & "Wtsapi32.dll") $SendMessageResult = DllCall($wtsapiCall,"BOOL","WTSSendMessageA","HANDLE","WTS_CURRENT_SERVER_HANDLE","DWORD",$SessionId[0],"str",DllStructGetData($pTitle, "Title"),"DWORD",DllStructGetSize($pTitle),"str",DllStructGetData($pMessage, "Message"),"DWORD",DllStructGetSize($pMessage),"DWORD",49,"DWORD",$ShutDownWindowTimeout,"DWORD",DllStructGetPtr($pResponse),"BOOL","1") $SendMessageResult[3] & "," & $SendMessageResult[4] & "," & $SendMessageResult[5] & "," & $SendMessageResult[6] & "," & $SendMessageResult[7]& $SendMessageResult[8] & "," & $SendMessageResult[9] & "," & $SendMessageResult[10]) DllClose($wtsapiCall)


Which I compile and run the .exe just as the currently logged in user. I then have another program that runs the following code:

MsgBox(0, "TEST", ControlSetText("Scheduled Power Action", '', "Static2", "Test 213"))


On XP, it changes the text and returns that it worked. On W7, it does not change the text and returns "0". However, if I run the following code on W7:

MsgBox(0, "TEST", ControlGetText("Scheduled Power Action", "", "Static2"))


Then it displays the correct "Your computer is scheduled to REBOOT. Click CANCEL to keep working." text from the message box alert, so it does detect that it exists....it just can't seem to change it.

Edited by CGRemakes, 30 May 2012 - 04:13 PM.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users