
timsky
Active Members-
Posts
33 -
Joined
-
Last visited
Everything posted by timsky
-
2 ^ 62 = 4611686018427387905 ???
timsky replied to timsky's topic in AutoIt General Help and Support
Bilgus, thanks for iPow and operator64 Ticket is there: https://www.autoitscript.com/trac/autoit/ticket/3703 -
$iInt64 = Int(2 ^ 62, 2) ConsoleWrite($iInt64 & @lf) = 4611686018427387905 Bug starts at 2 ^ 49 and further. 2 ^ 63 gives -9223372036854775808 as result. Why negative? AutoIt 3.3.14.5. PS: I also found other math bug(s) in more complex code but can not determine where. Maybe it is related.
-
Int, Dec and Number return incorrect results
timsky replied to timsky's topic in AutoIt General Help and Support
Geir1983, I know that but thank you for explanation. czardas, BrewManNH, Melba23, thank you too -
Int, Dec and Number return incorrect results
timsky replied to timsky's topic in AutoIt General Help and Support
Melba23, Because I need to see how binary data will "look" in decimal. That's it. Binary - yes, but string (hex) works in most cases. I tried various combinations and you can see that these functions work as I expected but in some cases are limited by binary length of data. So how can I convert binary data to make Int and Number work with binary/string (hex) data? As I see now only Dec does the job as required by me. -
Int, Dec and Number return incorrect results
timsky replied to timsky's topic in AutoIt General Help and Support
Melba23, Then why Int works fine with string data except 4-byte case? Why Int works fine with both binary and string data if data is 1 byte (8bits)? Same with Number. In case of Number: Why hexademical (binary) data is correctly interpreted and starting 2+ bytes it get broken for binary but works fine for string... just like Int does? Double flag breaks Number (double) for binary data always and for string data starting from 5+ bytes. Dec with double flag set returns wrong data always. If you are right then Int and Number must return anything else but not "correct" results almost any time -
Int, Dec and Number return incorrect results
timsky replied to timsky's topic in AutoIt General Help and Support
Melba23, I do not understand what means "quite reasonably, not designed to be used on binary data". If so then why it is documented as feature? What functions are designed to do that? All mentioned functions do not return correct results each time. Seems like you did not read carefully my messages and ticket. Copy-paste for you: Just try Demo code from ticket to see all problems. Very strange question Because I need that for my program I am working on. It does not work correctly too. Take a closer look at sections 4), 5) and section 2), subsection b. in copy-paste above. -
Int, Dec and Number return incorrect results
timsky replied to timsky's topic in AutoIt General Help and Support
Opened Ticket #2992 https://www.autoitscript.com/trac/autoit/ticket/2992#ticket -
Int, Dec and Number return incorrect results
timsky replied to timsky's topic in AutoIt General Help and Support
And finally I tried Number(). It has issues too and works similar to Int() function: 1) Binary data is interpreted by Number() wrong way always if data is 2+ bytes. "Double" flag returns 0 2) String representation gives better results but still don't work with 4-byte data. "Double" flag returns correct number: 4292382090 just like Dec64 3) But starting 5 bytes of data String representationwith "Double" flag returns 0 Demo: Global $aBin[] = ["0xff", '0xffd8', '0xffd88d', '0xffd88d8a', '0xffd88d8abc', '0xffd88d8abcd1', '0xffd88d8abcd1e5', '0xffd88d8abcd1e5ff'] For $i = 0 To UBound($aBin) - 1 $real_str = $aBin[$i] $real_bin = Binary($real_str) ; MsgBox(0, VarGetType($real_str), VarGetType($real_bin)) $sData = 'Hex: ' & @TAB & @TAB & $real_str & @LF & _ 'Binary: ' & @TAB & @TAB & StringLower($real_bin) & @LF & _ 'Dec32: ' & @TAB & @TAB & Dec(StringTrimLeft($real_str, 2), 1) & @LF & _ ; added 'Dec: (auto)' & @TAB & @TAB & Dec(StringTrimLeft($real_str, 2)) & @LF & _ ; Renamed 'Dec64: ' & @TAB & @TAB & Dec(StringTrimLeft($real_str, 2), 2) & @LF & _ ; added 'Dec (double): ' & @TAB & @TAB & Dec(StringTrimLeft($real_str, 2), 3) & @LF & _ ; added 'Number32 <- String: ' & @TAB & @TAB & Number($real_str, 1) & @LF & _ ; added 'Number <- String: (auto)' & @TAB & @TAB & Number($real_str) & @LF & _ ; added 'Number64 <- String: ' & @TAB & @TAB & Number($real_str, 2) & @LF & _ ; added 'Number (double) <- String: ' & @TAB & @TAB & Number($real_str, 3) & @LF & _ ; added 'Number32 <- Binary ' & @TAB & @TAB & Number($real_bin, 1) & @LF & _ ; added 'Number <- Binary (auto)' & @TAB & @TAB & Number($real_bin) & @LF & _ ; added 'Number64 <- Binary ' & @TAB & @TAB & Number($real_bin, 2) & @LF & _ ; added 'Number (double) <- Binary ' & @TAB & @TAB & Number($real_bin, 3) & @LF & _ ; added 'Int32: ' & @TAB & @TAB & Int($real_str, 1) & @LF & _ 'Int (auto): ' & @TAB & @TAB & Int($real_str) & @LF & _ 'Int64: ' & @TAB & @TAB & Int($real_str, 2) & @LF & _ 'Int32 <- String: ' & @TAB & Int(String($real_str), 1) & @LF & _ 'Int (auto) <- String: ' & @TAB & Int(String($real_str)) & @LF & _ 'Int64 <- String: ' & @TAB & Int(String($real_str), 2) & @LF & _ 'Int32 <- Binary: ' & @TAB & Int($real_bin, 1) & @LF & _ 'Int (auto) <- Binary: ' & @TAB & Int($real_bin) & @LF & _ 'Int64 <- Binary: ' & @TAB & Int($real_bin, 2) MsgBox(524288, $real_str & " - " & BinaryLen($real_str) & ' bytes', $sData) Next -
Int, Dec and Number return incorrect results
timsky replied to timsky's topic in AutoIt General Help and Support
Melba23, Because I read file in binary mode and got strange results with Int(). My code was small demonstration of issues. Int64 of of 4-byte binary or string data anyway does not return correct data: There should be 4292382090 instead of -2585206 and -1970415361 for Int64. You can see that Binary data is interpreted by Int() wrong way always if data is 2+ bytes. String representation gives better results but still don't work with 4-byte data. Aren't these issues strange? Thank you for Dec() Dec64 works perfect and returns correct result for 4-byte binary or string data: 4292382090 Here is a bit modified version of your example: Global $aBin[] = ["0xff", '0xffd8', '0xffd88d', '0xffd88d8a', '0xffd88d8abc', '0xffd88d8abcd1', '0xffd88d8abcd1e5', '0xffd88d8abcd1e5ff'] For $i = 0 To UBound($aBin) - 1 $real_str = $aBin[$i] $real_bin = Binary($real_str) ; MsgBox(0, VarGetType($real_str), VarGetType($real_bin)) $sData = 'Hex: ' & @TAB & @TAB & $real_str & @LF & _ 'Binary: ' & @TAB & @TAB & StringLower($real_bin) & @LF & _ 'Dec32: ' & @TAB & @TAB & Dec(StringTrimLeft($real_str, 2), 1) & @LF & _ ; added 'Dec: (auto)' & @TAB & @TAB & Dec(StringTrimLeft($real_str, 2)) & @LF & _ ; Renamed 'Dec64: ' & @TAB & @TAB & Dec(StringTrimLeft($real_str, 2), 2) & @LF & _ ; added 'Dec (double): ' & @TAB & @TAB & Dec(StringTrimLeft($real_str, 2), 3) & @LF & _ ; added 'Int32: ' & @TAB & @TAB & Int($real_str, 1) & @LF & _ 'Int (auto): ' & @TAB & @TAB & Int($real_str) & @LF & _ 'Int64: ' & @TAB & @TAB & Int($real_str, 2) & @LF & _ 'Int32 <- String: ' & @TAB & Int(String($real_str), 1) & @LF & _ 'Int (auto) <- String: ' & @TAB & Int(String($real_str)) & @LF & _ 'Int64 <- String: ' & @TAB & Int(String($real_str), 2) & @LF & _ 'Int32 <- Binary: ' & @TAB & Int($real_bin, 1) & @LF & _ 'Int (auto) <- Binary: ' & @TAB & Int($real_bin) & @LF & _ 'Int64 <- Binary: ' & @TAB & Int($real_bin, 2) MsgBox(524288, $real_str & " - " & BinaryLen($real_str) & ' bytes', $sData) Next Double means scientific notation? Dec (double) return strange results too starting from 1-byte data: -
Seems like Int function works incorrect sometimes. Int of binary data works fine on 1-byte data only. 2+ byte data always returns incorrect results. Int of 4-byte binary data and it's string representation: Int of 4-byte binary data returns bswap as result. Int64 of string representation of 4-byte binary data returns 32-bit signed integer. $bin = Binary('0xff'); 1 BYTES MsgBox(524288, BinaryLen($bin) & ' ' & VarGetType($bin) & ' bytes', 'HEX: ' & $bin & @LF & 'Int: ' & Int($bin) & @LF & 'Int32 <- String: ' & Int(String($bin), 1) & @LF & 'Int (auto) <- String: ' & Int(String($bin)) & @LF & 'Int64 <- String: ' & Int(String($bin), 2)) $bin = Binary('0xffd8'); 2 BYTES MsgBox(524288, BinaryLen($bin) & ' ' & VarGetType($bin) & ' bytes', 'HEX: ' & $bin & @LF & 'Int: ' & Int($bin) & @LF & 'Int32 <- String: ' & Int(String($bin), 1) & @LF & 'Int (auto) <- String: ' & Int(String($bin)) & @LF & 'Int64 <- String: ' & Int(String($bin), 2)) $bin = Binary('0xffd88d'); 3 BYTES MsgBox(524288, BinaryLen($bin) & ' ' & VarGetType($bin) & ' bytes', 'HEX: ' & $bin & @LF & 'Int: ' & Int($bin) & @LF & 'Int32 <- String: ' & Int(String($bin), 1) & @LF & 'Int (auto) <- String: ' & Int(String($bin)) & @LF & 'Int64 <- String: ' & Int(String($bin), 2)) $bin = Binary('0xffd88d8a'); 4 BYTES MsgBox(524288, BinaryLen($bin) & ' ' & VarGetType($bin) & ' bytes', 'HEX: ' & $bin & @LF & 'Int: ' & Int($bin) & @LF & 'Int32 <- String: ' & Int(String($bin), 1) & @LF & 'Int (auto) <- String: ' & Int(String($bin)) & @LF & 'Int64 <- String: ' & Int(String($bin), 2)) $bin = Binary('0xffd88d8abc'); 5 BYTES MsgBox(524288, BinaryLen($bin) & ' ' & VarGetType($bin) & ' bytes', 'HEX: ' & $bin & @LF & 'Int: ' & Int($bin) & @LF & 'Int32 <- String: ' & Int(String($bin), 1) & @LF & 'Int (auto) <- String: ' & Int(String($bin)) & @LF & 'Int64 <- String: ' & Int(String($bin), 2)) $bin = Binary('0xffd88d8abcd1'); 6 BYTES MsgBox(524288, BinaryLen($bin) & ' ' & VarGetType($bin) & ' bytes', 'HEX: ' & $bin & @LF & 'Int: ' & Int($bin) & @LF & 'Int32 <- String: ' & Int(String($bin), 1) & @LF & 'Int (auto) <- String: ' & Int(String($bin)) & @LF & 'Int64 <- String: ' & Int(String($bin), 2)) $bin = Binary('0xffd88d8abcd1e5'); 7 BYTES MsgBox(524288, BinaryLen($bin) & ' ' & VarGetType($bin) & ' bytes', 'HEX: ' & $bin & @LF & 'Int: ' & Int($bin) & @LF & 'Int32 <- String: ' & Int(String($bin), 1) & @LF & 'Int (auto) <- String: ' & Int(String($bin)) & @LF & 'Int64 <- String: ' & Int(String($bin), 2)) $bin = Binary('0xffd88d8abcd1e5ff'); 8 BYTES MsgBox(524288, BinaryLen($bin) & ' ' & VarGetType($bin) & ' bytes', 'HEX: ' & $bin & @LF & 'Int: ' & Int($bin) & @LF & 'Int32 <- String: ' & Int(String($bin), 1) & @LF & 'Int (auto) <- String: ' & Int(String($bin)) & @LF & 'Int64 <- String: ' & Int(String($bin), 2)) AutoIt 3.3.12.0 x86 and x64 OS: Win 7 x64 SP1
-
yn0t mentioned a bug with daylight saving but did not fully fixed it. Here is Fz's (original) fixed script: #include <Date.au3> $ntpServer = "pool.ntp.org" UDPStartup() Dim $socket = UDPOpen(TCPNameToIP($ntpServer), 123) If @error <> 0 Then MsgBox(0, "", "Can't open connection!") Exit EndIf $status = UDPSend($socket, MakePacket("1b0e01000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000")) If $status = 0 Then MsgBox(0, "ERROR", "Error while sending UDP message: " & @error) Exit EndIf $data = "" While $data = "" $data = UDPRecv($socket, 100) Sleep(100) WEnd UDPCloseSocket($socket) UDPShutdown() ;MsgBox(0, "UDP DATA RAW", $data) $unsignedHexValue = StringMid($data, 83, 8); Extract time from packet. Disregards the fractional second. ;MsgBox(0, "UDP DATA", $unsignedHexValue) $value = UnsignedHexToDec($unsignedHexValue) $TZinfo = _Date_Time_GetTimeZoneInformation() ;$TZoffset = $TZinfo[1] * - 1 $UTC = _DateAdd("s", $value, "1900/01/01 00:00:00") If $TZinfo[0] <> 2 Then ; 0 = Daylight Savings not used in current time zone / 1 = Standard Time $TZoffset = ($TZinfo[1]) * - 1 Else ; 2 = Daylight Savings Time $TZoffset = ($TZinfo[1] + $TZinfo[7]) * - 1 EndIf MsgBox(0, "", "Time from NTP Server UTC: " & $UTC & @CRLF & _ "Time from NTP Server Local Offset: " & _DateAdd("n", $TZoffset, $UTC) & @CRLF & _ "Time from Local Computer Clock: " & _NowCalc()) ;************************************************************************************************** ;** Fuctions ************************************************************************************** ;************************************************************************************************** Func MakePacket($d) Local $p = "" While $d $p &= Chr(Dec(StringLeft($d, 2))) $d = StringTrimLeft($d, 2) WEnd Return $p EndFunc ;==>MakePacket ;************************************************************************************************** Func UnsignedHexToDec($n) $ones = StringRight($n, 1) $n = StringTrimRight($n, 1) Return Dec($n) * 16 + Dec($ones) EndFunc ;==>UnsignedHexToDec ;************************************************************************************************** yn0t's fixed script (GUI): #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <Date.au3> $AppTitle = "NTP Client" $AppVersion = "1.0" $AppTitleVersion = $AppTitle & " v" & $AppVersion #Region ### START Koda GUI section ### $frmMain = GUICreate($AppTitleVersion, 498, 271, 239, 155) $txtNTPServer = GUICtrlCreateInput("pool.ntp.org", 72, 8, 417, 21) $Label1 = GUICtrlCreateLabel("NTP Server:", 8, 10, 63, 17) $cmdQuery = GUICtrlCreateButton("Query", 416, 240, 75, 25, $WS_GROUP) $grpNTPServer = GUICtrlCreateGroup("NTP Server", 8, 32, 481, 73) $Label2 = GUICtrlCreateLabel("NTP Server UTC:", 48, 52, 88, 17) $txtNTPServerUTC = GUICtrlCreateInput("", 136, 48, 345, 21, BitOR($ES_AUTOHSCROLL, $ES_READONLY)) $txtNTPServerLocalTime = GUICtrlCreateInput("", 136, 72, 345, 21, BitOR($ES_AUTOHSCROLL, $ES_READONLY)) $Label5 = GUICtrlCreateLabel("NTP Server Local Time:", 18, 76, 118, 17) GUICtrlCreateGroup("", -99, -99, 1, 1) $grpLocal = GUICtrlCreateGroup("Local Computer", 8, 112, 481, 121) $Label3 = GUICtrlCreateLabel("Time Zone:", 73, 134, 58, 17) $Label4 = GUICtrlCreateLabel("Offset (hours):", 61, 154, 70, 17) $Label6 = GUICtrlCreateLabel("UTC Time:", 76, 177, 55, 17) $txtTimeZone = GUICtrlCreateInput("", 136, 128, 345, 21, BitOR($ES_AUTOHSCROLL, $ES_READONLY)) $txtOffset = GUICtrlCreateInput("", 136, 152, 345, 21, BitOR($ES_AUTOHSCROLL, $ES_READONLY)) $txtLocalUTCTime = GUICtrlCreateInput("", 136, 176, 345, 21, BitOR($ES_AUTOHSCROLL, $ES_READONLY)) $txtLocalTime = GUICtrlCreateInput("", 136, 200, 345, 21, BitOR($ES_AUTOHSCROLL, $ES_READONLY)) $Label9 = GUICtrlCreateLabel("Local Time:", 72, 199, 59, 17) GUICtrlCreateGroup("", -99, -99, 1, 1) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### ;************************************************************************************************** ;** Functions ************************************************************************************* ;************************************************************************************************** Func MakePacket($d) Local $p = "" While $d $p &= Chr(Dec(StringLeft($d, 2))) $d = StringTrimLeft($d, 2) WEnd Return $p EndFunc ;==>MakePacket Func UnsignedHexToDec($n) $ones = StringRight($n, 1) $n = StringTrimRight($n, 1) Return Dec($n) * 16 + Dec($ones) EndFunc ;==>UnsignedHexToDec Func QueryNTP($ntpServer) UDPStartup() Dim $socket = UDPOpen(TCPNameToIP($ntpServer), 123) If @error <> 0 Then MsgBox(0, "", "Can't open connection!") Return 0 EndIf $status = UDPSend($socket, MakePacket("1b0e01000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000")) If $status = 0 Then MsgBox(0, "ERROR", "Error while sending UDP message: " & @error) Return 0 EndIf $data = "" While $data = "" $data = UDPRecv($socket, 100) Sleep(100) WEnd UDPCloseSocket($socket) UDPShutdown() $unsignedHexValue = StringMid($data, 83, 8) ; Extract time from packet. Disregards the fractional second. $value = UnsignedHexToDec($unsignedHexValue) $TZinfo = _Date_Time_GetTimeZoneInformation() ;msgbox(4096, "", $TZinfo[0]) $UTC = _DateAdd("s", $value, "1900/01/01 00:00:00") If $TZinfo[0] <> 2 Then ; 0 = Daylight Savings not used in current time zone / 1 = Standard Time $TZoffset = ($TZinfo[1]) * - 1 $TimeZone = $TZinfo[2] Else ; 2 = Daylight Savings Time $TZoffset = ($TZinfo[1] + $TZinfo[7]) * - 1 $TimeZone = $TZinfo[5] EndIf GUICtrlSetData($txtNTPServerUTC, $UTC) GUICtrlSetData($txtNTPServerLocalTime, _DateAdd("n", $TZoffset, $UTC)) GUICtrlSetData($txtTimeZone, $TimeZone) GUICtrlSetData($txtOffset, $TZoffset / 60) GUICtrlSetData($txtLocalUTCTime, _DateAdd("n", $TZoffset * - 1, _NowCalc())) GUICtrlSetData($txtLocalTime, _NowCalc()) EndFunc ;==>QueryNTP Func CenterWindow($window_title) $position = WinGetPos($window_title) WinMove($window_title, "", (@DesktopWidth / 2) - ($position[2] / 2), (@DesktopHeight / 2) - ($position[3] / 2)) EndFunc ;==>CenterWindow CenterWindow($AppTitleVersion) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $cmdQuery QueryNTP(GUICtrlRead($txtNTPServer)) Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd and stealthf117jm's fixed script (Synchronizer): #include <Date.au3> $ntpServer = "pool.ntp.org" UDPStartup() Dim $socket = UDPOpen(TCPNameToIP($ntpServer), 123) If @error <> 0 Then MsgBox(0, "", "Can't open connection!") Exit EndIf $status = UDPSend($socket, MakePacket("1b0e01000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000")) If $status = 0 Then MsgBox(0, "ERROR", "Error while sending UDP message: " & @error) Exit EndIf $data = "" While $data = "" $data = UDPRecv($socket, 100) Sleep(100) WEnd UDPCloseSocket($socket) UDPShutdown() ;MsgBox(0, "UDP DATA RAW", $data) $unsignedHexValue = StringMid($data, 83, 8); Extract time from packet. Disregards the fractional second. ;MsgBox(0, "UDP DATA", $unsignedHexValue) $value = UnsignedHexToDec($unsignedHexValue) $TZinfo = _Date_Time_GetTimeZoneInformation() ;$TZoffset = $TZinfo[1] * - 1 $UTC = _DateAdd("s", $value, "1900/01/01 00:00:00") If $TZinfo[0] <> 2 Then ; 0 = Daylight Savings not used in current time zone / 1 = Standard Time $TZoffset = ($TZinfo[1]) * - 1 Else ; 2 = Daylight Savings Time $TZoffset = ($TZinfo[1] + $TZinfo[7]) * - 1 EndIf ;~ Extracts the data & time into vars ;~ Date format & offsets ;~ 2009/12/31 19:26:05 ;~ 1234567890123456789 [1 is start of string] $m = StringMid($UTC, 6, 2) $d = StringMid($UTC, 9, 2) $y = StringMid($UTC, 1, 4) $h = StringMid($UTC, 12, 2) $mi = StringMid($UTC, 15, 2) $s = StringMid($UTC, 18, 2) ;~ MsgBox(0,"",$m & "/" & $d & "/" & $y & " " & $h & ":" & $mi & ":" & $s) ; Visual test of obtained date ;~ Sets the new current time to the computer $tCurr = _Date_Time_EncodeSystemTime($m, $d, $y, $h, $mi, $s) _Date_Time_SetSystemTime(DllStructGetPtr($tCurr)) ;************************************************************************************************** ;** Fuctions ************************************************************************************** ;************************************************************************************************** Func MakePacket($d) Local $p = "" While $d $p &= Chr(Dec(StringLeft($d, 2))) $d = StringTrimLeft($d, 2) WEnd Return $p EndFunc ;==>MakePacket ;************************************************************************************************** Func UnsignedHexToDec($n) $ones = StringRight($n, 1) $n = StringTrimRight($n, 1) Return Dec($n) * 16 + Dec($ones) EndFunc ;==>UnsignedHexToDec ;************************************************************************************************** Thank you very much guys!
-
I have question about SQLite.au3. Changelog says that there is just one change: I compared it with version from 3.3.0.0 and there is a lot of differences.Can I use just SQLite.au3 from last beta with AutoIt 3.3.0.0?
-
What bug?
-
Thanks for so fast replies guys!
-
:offtop: IE 8 has same rendering issues as FF and renders pages similar way. Looks like it is based on same engine. Hope I am wrong...
-
Hi. I have AutoIt 3.3 installed and it contains SQLite 3.6.7. There is newer version on the site 3.6.13 that has lot of fixes: http://www.sqlite.org/changes.html Can I use new version 3.6.13 instead of 3.6.7 with UDF coded for 3.6.7 (UDF from AutoIt 3.3 installer) or there might be some issues?
-
Is it possible to login a user(s) in background?
-
Hello. Acording to this thread http://www.autoitscript.com/forum/index.php?showtopic=55546 an explorer.exe (windows shell) must be running in order to lot of _IE* functions work. Tried this: $start = RunAs('user', @ComputerName, 'password', 1, @WindowsDir & '\explorer.exe', @UserProfileDir)with various working directories with no positive result. Explorer.exe closes immediately. How can i start shell of another user? Actually only important things I need are _IEBodyReadText() and _IEQuit() functions.
-
Do anyboady have an idea how to avoid that isuue? PS: How is RunAs/RunAsWait working if Windows's native CMD.exe that was started with SYSTEM privileges can't start another app under Administrator at all?
-
Worst thing for me is that my app is started by Service and I can't find a way out except relogon
-
How is RunAs/RunAsWait working if Windows's native CMD.exe that was started with SYSTEM privileges can't start another app under Administrator at all?
-
It have to be scheduled in order to make it run under SYSTEM account (privileges). If any Service starts my (or any other) program then it runs with SYSTEM privileges too and in this condition my program can start another process with Administrator (or other user except SYSTEM) not more than 32 times. Your script works not more than 32 times too if it is started by a Service or Task Scheduler using command line: at {HOUR}:{MIN} /interactive {Path to executable}\Test.exe. This Task Scheduler command line makes a program start with SYSTEM privileges, just like it was started by a Service. Here is the log of your scrtipt:
-
This problem exists on Windows XP SP 3 EN x86 too! I created a new script to test the problem fast: #Include <Process.au3> If WinExists(@ScriptName) Then Exit AutoItWinSetTitle(@ScriptName) $login = IniRead(@ScriptDir & '\config.ini', 'Main', 'Login', '') If $login = '' Then $login = 'Administrator' $pass = IniRead(@ScriptDir & '\config.ini', 'Main', 'Pass', '') If $pass = '' Then $pass = '' $logonType = IniRead(@ScriptDir & '\config.ini', 'Main', 'LogonType', '') If $logonType = '' Then $logonType = 0 If $CmdLineRaw = 'schedule' Then $hour = @HOUR $min = @MIN + 1 $command = 'at ' & $hour & ':' & $min & ' /interactive ' & @ScriptDir & '\' & @ScriptName _RunDOS ($command) Exit Else $i = 0 While 1 $i = $i + 1 $run = RunAs($login, @ComputerName, $pass, $logonType, 'c:\WINDOWS\system32\calc.exe', @ScriptDir) If @error Then Exit $file = FileOpen(@ScriptDir & '\log.txt', 1) FileWriteLine($file, $i & ' - ' & @HOUR &':'& @MIN &':'& @SEC) ProcessClose($run) Sleep(1000) Wend EndIf All is need to do to test is to compile it to exe and start it with command line Test.exe schedule Also it is useful to use a config.ini: PS: Also foud that if I schedule CMD.exe after logoff/logon or reboot manual start of program (runas /noprofile /user:server\administrator "c:\WINDOWS\system32\calc.exe") do not work at all and I get this error: RUNAS ERROR: Unable to run - c:\WINDOWS\system32\calc.exe 5: Access is denied.