Jump to content

Administrator System - Block Applications


Recommended Posts

i dont find anything related to Windows UAC in your code

My code:

PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.

Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners.

MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. 

Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression.

Link to post
Share on other sites

ReaperX,

Upon using your code i found that because of the for while loop the more number of applications , much more time it takes for the script to block the program
Due to which sometimes i see a white glance of notepad

Solution:

I have already made a script like that, it uses registry
Just have a look
Code :

#OnAutoItStartRegister "Startup"
#RequireAdmin
#include <File.au3>

;Author Phoenix XL
;modified 21/05/2013

;block notepad
BlockApplication('notepad.exe')

;unblock when the user closes the Msgbox
MsgBox(64, 'Phoenix XL', 'Notepad Blocked as a Demo...' & @CRLF & 'Notepad would be unblocked upon exit.')
BlockApplication('notepad.exe', 0)
Exit

Func Startup()

    Global $s_regpath
    If @OSArch = "X86" Then
        $s_regpath = 'HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer'
    Else
        $s_regpath = 'HKCU64\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer'
    EndIf

    ;all okay then return
    If RegRead($s_regpath, "DisallowRun") = 1 Then Return

    ;we have to write the registry and restart the explorer.
    RegWrite($s_regpath, 'DisallowRun', 'REG_DWORD', 1)
    If @error Then Exit -1

    ;killing explorer and restarting the same would create a unwanted window. Therefore use a batch file.

    ;make the batch file to run the explorer.
    $s_batch = _TempFile(@TempDir, "~", ".bat")
    FileWrite($s_batch, "taskkill /im explorer.exe /f" & @CRLF & "start explorer" & @CRLF & "exit")
    ProcessClose("explorer.exe")


    ;kill and restart.
    ShellExecuteWait($s_batch, "", "", "open", @SW_HIDE)
    FileDelete($s_batch) ;delete the temp file.

EndFunc   ;==>Startup


Func BlockApplication($sAppname, $fBlock = True)

    ;block or unblock an application.
    Switch $fBlock
        Case True
            Return RegWrite($s_regpath & '\DisallowRun', 'block ' & _GetAppName($sAppname), 'REG_SZ', $sAppname)
        Case Else
            Return RegDelete($s_regpath & '\DisallowRun', 'block ' & _GetAppName($sAppname))
    EndSwitch

    ;set error otherwise.
    Return SetError(1, 1, 0)
EndFunc   ;==>BlockApplication

Func _GetAppName($sAppname)
    ;delete the extension from the name of the application
    Return StringRegExpReplace($sAppname, "(.*)\..*$", "\1")
EndFunc   ;==>_GetAppName

Regards
Phoenix XL

Edited by PhoenixXL

My code:

PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.

Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners.

MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. 

Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression.

Link to post
Share on other sites

tell me what do u think about my code

Due to which sometimes i see a white glance of notepad

Upon seeing it the user may try to find your process and kill it Edited by PhoenixXL

My code:

PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.

Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners.

MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. 

Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression.

Link to post
Share on other sites

Thnx for the feedback ;)

My code:

PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.

Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners.

MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. 

Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression.

Link to post
Share on other sites
  • 11 months later...

Hi PhoenixXL,

nice code. I'am using Windows7 Prof. 64Bit and i get a returncode of 0 when the RegWrite within the BlockApplication function is called. Somehow i can't write into the DisallowRun Key. (by the way: i can't see the key. Is it normal?). Some idea?

thanks in advance

Sundance

Link to post
Share on other sites

the script was for 32bit only, i have updated it for to support 64bit windows even.

Recheck if it works..!

P.S. its almost a year the last post of this topic was made, therefore please don't post new queries(Necroing), rather start a new topic.

Regards :)

Edited by PhoenixXL

My code:

PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.

Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners.

MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. 

Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression.

Link to post
Share on other sites

Hi PhoenixXL,

thanks for the headsup and the modification of the code. I've tried it today on both 32 and 64bit but both show the same error. Win7 won't let me write to that reg position. Will see if i can identify the problem more closer...

 

PS: So this is now no more an old topic i guess?   :huh2:

Link to post
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
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By photonblaster
      I am looking for advice on next trouble shooting steps for my problem.  I have researched this over the last three days and still not solved it.  The main reason "run Scite works, exe doesnt" occurs seems to be duplicate names in executable files but I made sure I do not have that problem.
      I have a "trivial" script that watches for a login window to pop up, inserts PW and enter/closes.  It worked for a year then I experimented with #RequireAdmin on another problem and ran/compiled this one with RequireAdmin to check out what happens as a learning excercise.  Now the compiled version MUST be run with admin rights, and I get the UAC approval window  which I must avoid in my application, but the SciTe editor version runs from the tools menu (F5) just fine, no UAC.  The correlation between using RequireAdmin for a while  and the run problem is probably just a coincidence, but I am suspicious.
       
      #include <MsgBoxConstants.au3> ;#RequireAdmin ;trying with and without #requireadmin Opt("SendCapslockMode", 0) ;make sure caps are off Send("{CapsLock off}") Local $myTitle = "User Login Dialog" Local $myPW = "password" & "{ENTER} ; Wait max 10 seconds for the Sign In window to appear. If Not (WinWait($myTitle, "", 10)) Then MsgBox($MB_SYSTEMMODAL + $MB_ICONERROR, "Error", "LogIn window did not appear or is timed out") EndIf If WinActivate($myTitle) Then ControlSend($myTitle, "", "", $myPW ) ;alternate, also works in editor ;Send($myPW & "{ENTER}") ;MsgBox($MB_SYSTEMMODAL + $MB_ICONERROR, "INFO", "SENT $myPW enter") Else MsgBox($MB_SYSTEMMODAL + $MB_ICONERROR, "Error", "Sign In Window did not activate") EndIf Sleep(2000) If (WinExists($myTitle)) Then MsgBox($MB_SYSTEMMODAL + $MB_ICONERROR, "Error", "LOGIN FAILED") EndIf More info that may be relevant, at least as background info: The LogIn window is from a custom addin to Excel, does not have control ID access to the user/pw entry locations, just the enter/cancel buttons are found by AU3Info.  Thus I had to resort to Send, or ControlSend with just the default selection on popup of where the entries go.  Fortunately the UserID area remains populated between uses and the PW entry "window" is automatically selected at window popup so I just enter PW text and {enter}.
      I can run the compiled file as administrator, OK the UAC window "do you want to allow...", and it runs. (right click the file in file explorer, select "Run as Administrator".
      Trying to accept this issue I tried ways to "bypass" the UAC window.   I followed instructions on CNET to run the exe file as administrator automatically but the UAC window still comes up: Always run a program in administrator mode in Windows 10 - CNET
      I tried to create a shortcut to the exe file through the scheduler following these instructions (other links give the same set of instructions), did not seem to run at all, could not track down any errors I might have made. Open any program as administrator without UAC prompt (winaero.com)
      Is there any system settings permanently changed by RequireAdmin?  What should I look at to have the exe file run without the UAC window?
      Regards and stay healthy!
    • By nacerbaaziz
      hello autoit team
      is there any wey to check if any process run as admin or no?
      i mean e.g if i want to restart any process, now i have the ability to get the process path and commands line
      what i need is a wey to check if the process was runing as admin or no to restart it with the same state.
      here is the part that am using it to restart the process
      func _processRestart($i_pid, $s_ProcessPath) if not (ProcessExists($i_ProcessPid)) then return SetError(1, 0, -1) local $s_ProcessWorkDir = _WinAPI_GetProcessWorkingDirectory($i_ProcessPid) ProcessClose($i_ProcessPid) ProcessWaitClose($i_ProcessPid) ProcessWait(ShellExecute($i_pid,"", $s_ProcessWorkDir)) ProcessesGetList() return true endFunc thanks in advance
    • By morion84
      Hi, when I call a MsgBox function I can use a "$MB_SERVICE_NOTIFICATION" flag so it will be displayed "on the current active desktop, even if there is no user logged on to the computer.". That works just great. Is there a way to do the same to Autoit GUI Form so it will be visible on desktop even if running from system account and user is not logged?
    • By Psyllex
      I'm trying to install some setup stuff on Win10. 
       
      One part of the script requires just regular user privileges but the other requires admin privileges.  When I run it from the Autoit Editor it works like a champ.  When I build it, Windows slaps the admin stamp on it and then when I attempt to run the part that only requires regular users....it gets all hosed up. 
      Is there a way to remove #RequireAdmin? 

      I've tried RunAs(username, "", myPassword, "", "cmd.exe", "") but that never seems to work.
      Can someone help me out?
    • By nacerbaaziz
      Hello all
      I have a question please
      Is there a way to request the script for administrator privileges if a particular condition is met??
      example
      local $path = RegRead("HKEY_CURRENT_USER\Software\test", "fullpath")
      if $fullPath = @scriptFullPath then
      Request for administrator privileges
      main()
      else
      main()
      endIf
      I hope to find a solution here
      Greetings to all
×
×
  • Create New...