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 comment
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 comment
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 comment
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 comment
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 comment
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 comment
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 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

×
×
  • Create New...