Jump to content

Script to create a FILE which is not allowed to be COPIED


rshnGhost
 Share

Recommended Posts

Hi,

I am new to AutoIt coding world.

I would like to have you experts help to help me with a code which creates a file which cannot be copied.

Script creates a file and any user should not be allowed to make its copies, but have permission to edit or delete.

Thank you

Link to comment
Share on other sites

Hi,

I am new to AutoIt coding world.

I would like to have you experts help to help me with a code which creates a file which cannot be copied.

Script creates a file and any user should not be allowed to make its copies, but have permission to edit or delete.

Thank you

Link to comment
Share on other sites

51 minutes ago, rshnGhost said:

Script creates a file and any user should not be allowed to make its copies, but have permission to edit or delete.

Impossible to do this. If you can edit it, you can copy it, simple as that.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

  • Moderators

There are some technologies out there that allow you to provide users access to files and edit, but not copy them to a local machine (VMware's AirWatch is a good example), but I agree with BrewMan you are not going to find that natively with AutoIt.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

Once you have access to copy the contents of a file, you can paste it into anything you want. So even if you can't copy the actual file, once you have editing access you lose anything gained.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

11 minutes ago, JLogan3o13 said:

There are some technologies out there that allow you to provide users access to files and edit, but not copy them to a local machine (VMware's AirWatch is a good example), but I agree with BrewMan you are not going to find that natively with AutoIt.

Oh..

Thank you 

Link to comment
Share on other sites

7 minutes ago, BrewManNH said:

Once you have access to copy the contents of a file, you can paste it into anything you want. So even if you can't copy the actual file, once you have editing access you lose anything gained.

Edit is done with only privileged application with some kind of authentication.

Any ways thanks

Link to comment
Share on other sites

So, thinking abstractly about the question...Are you meaning a form of copy protection to not be used on another machine? add an encryption based on a hardware property(ie MAC address or HD serial number)...

outside of that to make it not able to be copied have it encrypted so that the file can be copied but not read by another machine

last thought regarding this, have the text actually be created by pixel dots or images, a simple copy/paste into an editor would not yield usable text...

 

wish I was versed in Autoit a little better as to be able to provide snippets to get you started, but finding the solution to the idea is most of the fun anyway

 

Good luck

Link to comment
Share on other sites

Was bored, this would get you started

#include <Crypt.au3>
#include <GUIConstants.au3>
#include <File.au3>
#include <WindowsConstants.au3>
#include <WinAPIShellEx.au3>
#include <GuiEdit.au3>
#include <MsgBoxConstants.au3>

_Crypt_Startup()

; Declare SHA_256 because AutoIt has it commented out in the Crypt.au3 file by default
Global Const $sCryptKey = "~!Th1s f1l3 1s pr0t3t3ed!~"
Enum $idProcEdit = 1000

Global $hNewWindowProc = DllCallbackRegister("NewWindowProc", "lresult", "hwnd;uint;wparam;lparam;uint_ptr;dword_ptr")
Global $pNewWindowProc = DllCallbackGetPtr($hNewWindowProc)

Global $hMain = GUICreate("Encrypt Reader Pro", 800, 600)
Global $hMenu = GUICtrlCreateMenu("&File")
Global $idOpen = GUICtrlCreateMenuItem("Open", $hMenu)
Global $idCloseFile = GUICtrlCreateMenuItem("Close", $hMenu)
Global $idSave = GUICtrlCreateMenuItem("Save", $hMenu)
Global $idSaveAs = GUICtrlCreateMenuItem("Save As...", $hMenu)
Global $edtEditor = GUICtrlCreateEdit("", 0, 0, 800, 580)
Global $hEditor = GUICtrlGetHandle($edtEditor)
Global $sFileName = ""

GUISetState(@SW_SHOW, $hMain)

_WinAPI_SetWindowSubclass($hEditor, $pNewWindowProc, $idProcEdit)

While (True)
    Switch (GUIGetMsg())
        Case $GUI_EVENT_CLOSE
            CloseEditor()
        Case $idOpen
            Open(FileOpenDialog("Open File", "::{450D8FBA-AD25-11D0-98A8-0800361B1103}", "Crypt Files (*.crpt)"))
        Case $idCloseFile
            GUICtrlSetData($edtEditor, "")
        Case $idSave
            Save($sFileName)
        Case $idSaveAs
            Local $sTmp = FileSaveDialog("Save File As", "::{450D8FBA-AD25-11D0-98A8-0800361B1103}", "Crypt Files (*.crpt)")
            If (Not @error) Then
                If (FileExists($sTmp)) Then
                    If (MsgBox($MB_YESNO, "Overwrite?", "That file already exists. Would you like to overwrite it?") = $IDYES) Then
                        $sFileName = $sTmp
                        ContinueLoop
                    EndIf
                Else
                    $sFileName = $sTmp
                EndIf

                Save($sFileName)
            EndIf
    EndSwitch
WEnd

Func CloseEditor()
    _WinAPI_RemoveWindowSubclass($hEditor, $pNewWindowProc, $idProcEdit)
    Exit 0
EndFunc

Func Open(Const $sOpenFile)
    If (FileExists($sOpenFile)) Then
        Local $hFile = FileOpen($sOpenFile)
        Local $sData = FileRead($hFile)

        If ($sData) Then
            GUICtrlSetData($edtEditor, BinaryToString(_Crypt_DecryptData($sData, $sCryptKey, $CALG_AES_256)))
        EndIf
    EndIf
EndFunc

Func Save(Const $sSaveFile)
    If ($sSaveFile) Then
        Local $hFile = FileOpen($sSaveFile, $FO_OVERWRITE)
        Local $sData = GUICtrlRead($edtEditor)

        If ($sData) Then
            FileWrite($hFile, _Crypt_EncryptData($sData, $sCryptKey, $CALG_AES_256))
            FileClose($hFile)
        EndIf
    EndIf
EndFunc

Func NewWindowProc($hWnd, $iMsg, $wParam, $lParam, $uIdSubclass, $dwRefData)
    #forceref $hWnd, $iMsg, $wParam, $lParam, $uIdSubclass, $dwRefData
    Switch ($uIdSubclass)
        Case $idProcEdit
            Switch ($iMsg)
                Case $WM_CHAR
                    ; Ctrl+A
                    If ($wParam = 1) Then
                        Return _GUICtrlEdit_SetSel($hWnd, 0, -1)
                    ; Ctrl+S
                    ElseIf ($wParam = 19) Then
                        If (not $sFileName) Then
                            Local $sTmp = FileSaveDialog("Save File As", "::{450D8FBA-AD25-11D0-98A8-0800361B1103}", "Crypt Files (*.crpt)")

                            If (Not @error) Then
                                If (FileExists($sTmp)) Then
                                    If (MsgBox($MB_YESNO, "Overwrite?", "That file already exists. Would you like to overwrite it?") = $IDYES) Then
                                        $sFileName = $sTmp
                                    EndIf
                                Else
                                    $sFileName = $sTmp
                                EndIf
                            EndIf
                        EndIf

                        Return Save($sFileName)
                    EndIf
                Case $WM_COPY
                    ConsoleWrite("User tried to copy me!" & @LF)
                    ; Return 0, we don't want the copy to go through!
                    Return 0

                Case $WM_KEYUP

            EndSwitch
    EndSwitch
    Return _WinAPI_DefSubclassProc($hWnd, $iMsg, $wParam, $lParam)
EndFunc

 

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