Jump to content
Sign in to follow this  
Skitty

_TempFile returns full path instead of filename..

Recommended Posts

Edit: Found a work around but any advice is still welcome!

Global $Rar = _TempFile(@ScriptDir, "DATA_", ".rar", 7)

How do you prevent the above code from returning a full path instead of the filename?

I'm trying to use it with this little project of mine. It's supposed to protect and hide files by archiving them with rar,exe

#include<File.au3>
#RequireAdmin
HotKeySet("{F2}","_Select")
Global $Rar = _TempFile(@ScriptDir, "DATA_", ".rar", 7)

While 1
    Sleep(360000)
WEnd

Func _Select()
    Local $I = InputBox("Command Center", " ", "", "", 200, 100)
    Switch $I
    Case "kill", "exit", "stop", "Kill", "Exit", "Stop", "KILL", "EXIT", "STOP"
        Exit
    Case "create", "Create", "CREATE"
        _create()
    Case "lock", "Lock", "LOCK"
        _lock()
    Case "unlock", "Unlock", "UNLOCK", "un-lock", "Un-lock", "UN-LOCK", "un lock", "Un lock", "UN LOCK", "Un Lock", "Un-Lock"
        _unlock()
    Case "google", "Google", "GOOGLE"
            ShellExecute("http://www.google.com")
        Case "au3"
            ShellExecute("http://www.autoitscript.org")
        Case Else
            MsgBox(0, "Syntax error", "'" & $I & "'" & " is not recognized as an internal or external command." & _
                    @LF & "Correct your syntax and try again.")
    EndSwitch
EndFunc


Func _create()
$folder = @ScriptDir & "\Archive"
DirCreate(@ScriptDir & "\Archive")
_FileCreate(@ScriptDir & "\Archive\desktop.ini")
FileInstall("C:\W7\lock.ico",@ScriptDir & "\Archive\lock.ico")
$ico = @ScriptDir & "\Archive\lock.ico"
IniWriteSection($folder & "\" & "Desktop.ini", ".ShellClassInfo", _
                "IconFile=" & $ico & @LF & _
                "IconIndex=0" & @LF & _
                "InfoTip=Folder ready for archiving!")
FileSetAttrib($folder & "\" & "Desktop.ini", "+H")
FileSetAttrib($folder, "+R")
FileSetAttrib($folder & "\lock.ico", "+SHR")
EndFunc

Func _lock()
    _TalkOBJ("At your command sir")
    $KB29 = InputBox("Set a password"," ","","",250,100)
    FileInstall("C:\W7\Rar.exe",@TempDir & "\Rar.exe")
    Sleep(1000)
    FileChangeDir(@TempDir)
    RunWait("rar a Data.rar -k -ow -m5 -hp" & $KB29 & " " & @ScriptDir & "\Archive",@TempDir,@SW_HIDE)
    FileMove(@TempDir & "\Data.rar", $Rar)
    ProcessClose("Rar.exe")
    FileChangeDir(@ScriptDir)
    DirCreate(@ScriptDir & "\KB29")
    _FileCreate(@ScriptDir & "\KB29\$~settings.ini")
    IniWriteSection(@ScriptDir & "\KB29\$~settings.ini", "KB29", _
    $Rar & "=" & $KB29)
    _TalkOBJ("Data archiving was successful")
EndFunc

Func _unlock()

EndFunc


Func _TalkOBJ($s_text)
  Local $o_speech = ObjCreate("SAPI.SpVoice")
  $o_speech.Speak($s_text)
  $o_speech = ""
EndFunc

You're going to have to edit the file install's if you wan't this to work!

It's causing a problem with the iniwritesection area. I need the iniwritesection function to only write the file name. I'm planning on adding a password encryption function so that even passwords area some what safe. Safe from what? no one really, just an interesting little project. supposedly rar.exe doc's say that using the -ph switch makes it impossible to open and view an archive when you use a password above 15-20 characters.

Edited by xJSLRx

Share this post


Link to post
Share on other sites

you can use this function for get file name

ConsoleWrite ( _GetNameByFullPath ( @ScriptFullPath ) & @CRLF )

Func _GetNameByFullPath ( $_FullPath )
    If Not FileExists ( $_FullPath ) Then Return 0
    $_FileName = StringSplit ( $_FullPath, '\' )
    Return $_FileName[$_FileName[0]]
EndFunc ;==> _GetNameByFullPath ( )

it give you scriptname like @Scriptname result ! Posted Image


AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Share this post


Link to post
Share on other sites

you can use this function for get file name

ConsoleWrite ( _GetNameByFullPath ( @ScriptFullPath ) & @CRLF )

Func _GetNameByFullPath ( $_FullPath )
    If Not FileExists ( $_FullPath ) Then Return 0
    $_FileName = StringSplit ( $_FullPath, '\' )
    Return $_FileName[$_FileName[0]]
EndFunc ;==> _GetNameByFullPath ( )

it give you scriptname like @Scriptname result ! Posted Image

Thanks! that's exactly what I needed!

Share this post


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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...