Quantcast
Channel: AutoIt v3 - General Help and Support
Viewing all articles
Browse latest Browse all 12506

How to execut a *REG with admin right ?

$
0
0

i toook very lon gtime to make a script that working perfectly now...

 

but the only thing is when i am executing the code everything work but autoit does not execute a reg file same way than a cmd file look at this code :

AutoIt         
               Case $Num_PC                   Local $MyNum_PC = InputBox("Nump_PC", "Que voulez vous comme numéro de pc?"&@CRLF &"Pour Planitec 2.0")                   Local Const $NumPCPath = "C:\Num_PC.reg"                   _FileCreate ( $NumPCPath )                   Local $hFileOpen = FileOpen($NumPCPath, $FO_APPEND)                         If $hFileOpen = -1 Then                               MsgBox($MB_SYSTEMMODAL, "", "An error occurred when reading the file.")                         Return False                         EndIf                   FileOpen ($NumPCPath)                   FileWriteLine($hFileOpen, "Windows Registry Editor Version 5.00")                   FileWriteLine($hFileOpen, @CRLF)                   FileWriteLine($hFileOpen, "[HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Session Manager\Environment]")                   FileWriteLine($hFileOpen,@CRLF)                   FileWriteLine($hFileOpen,'"NUM_PC"="999"')                      ShellExecute (@ScriptDir & "\NUM-PC.bat")                   FileClose ($NumPCPath)                   FileDelete ($NumPCPath)

ShellExecute (@ScriptDir & "\NUM-PC.bat") =

AutoIt         
:: BatchGotAdmin :------------------------------------- REM  --> Check for permissions >nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system" REM --> If error flag set, we do not have admin. if '%errorlevel%' NEQ '0' (     echo Requesting administrative privileges...     goto UACPrompt ) else ( goto gotAdmin ) :UACPrompt     echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"     set params = %*:"=""     echo UAC.ShellExecute "cmd.exe", "/c %~s0 %params%", "", "runas", 1 >> "%temp%\getadmin.vbs"     "%temp%\getadmin.vbs"     del "%temp%\getadmin.vbs"     exit /B :gotAdmin     pushd "%CD%"     CD /D "%~dp0" :-------------------------------------- C:\Num_PC.reg

The reg is not applied.


Viewing all articles
Browse latest Browse all 12506

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>