Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


how i delete file ?, please help me

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
gavrielsinvani
Cheater
Reputation: 0

Joined: 29 May 2019
Posts: 36

PostPosted: Mon Jun 03, 2019 1:09 pm    Post subject: how i delete file ?, please help me Reply with quote

i want delete file, and it's not working,

FileToCheck = [[GKExists.ini]] -- Change Patch for safley software.

file = io.open (FileToCheck)
os.remove(FileToCheck)
file:close()
Back to top
View user's profile Send private message
TheyCallMeTim13
Wiki Contributor
Reputation: 51

Joined: 24 Feb 2017
Posts: 976
Location: Pluto

PostPosted: Mon Jun 03, 2019 4:57 pm    Post subject: Reply with quote

Close the file before trying to remove it.
_________________
Back to top
View user's profile Send private message Visit poster's website
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1668

PostPosted: Mon Jun 03, 2019 7:39 pm    Post subject: Reply with quote

Code:
local path = TrainerOrigin or getMainForm() or path
local FileToCheck = path..'\\GKExists.ini' --- or dir of where 'GKExists.ini' located
local file = assert(io.open (FileToCheck, "r"))
local content = file:read("*all")
file:close()
os.execute("taskkill /F /IM GKExists.ini") -- to make sure no hidden process
os.remove(path.."\\GKExists.ini")
-- do something with content

_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL
Back to top
View user's profile Send private message
gavrielsinvani
Cheater
Reputation: 0

Joined: 29 May 2019
Posts: 36

PostPosted: Wed Jun 05, 2019 8:40 am    Post subject: Reply with quote

Corroder wrote:
Code:
local path = TrainerOrigin or getMainForm() or path
local FileToCheck = path..'\\GKExists.ini' --- or dir of where 'GKExists.ini' located
local file = assert(io.open (FileToCheck, "r"))
local content = file:read("*all")
file:close()
os.execute("taskkill /F /IM GKExists.ini") -- to make sure no hidden process
os.remove(path.."\\GKExists.ini")
-- do something with content

its not work Sad,
File is not deleted and it is discouraging
Back to top
View user's profile Send private message
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1668

PostPosted: Wed Jun 05, 2019 9:16 am    Post subject: Reply with quote

where or what is the directory/folder name which "GKExists.ini" locate?.
example: "C:\GKExists.ini" or "D:\Game\blabla\GKExists.ini" whatever?.

Then use:

os.remove("The directory where is GKExists.ini exist\\GKExists.ini")

Note: You need to close the file "GKExists.ini" first and the game which calls this file.

_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL
Back to top
View user's profile Send private message
gavrielsinvani
Cheater
Reputation: 0

Joined: 29 May 2019
Posts: 36

PostPosted: Wed Jun 05, 2019 9:35 am    Post subject: Reply with quote

Corroder wrote:
where or what is the directory/folder name which "GKExists.ini" locate?.
example: "C:\GKExists.ini" or "D:\Game\blabla\GKExists.ini" whatever?.

Then use:

os.remove("The directory where is GKExists.ini exist\\GKExists.ini")

Note: You need to close the file "GKExists.ini" first and the game which calls this file.

C
Code:

Its Create File (Working):
  file = io.open("GKExists.ini", "w")
  file:close()

Code:

its Remove File (Working):
    local FileToCheck = 'GKExists.ini' --- or dir of where 'GKExists.ini' located
    local file = assert(io.open (FileToCheck, "r"))
    local content = file:read("*all")
    file:close()
    os.execute("taskkill /F /IM GKExists.ini") -- to make sure no hidden process
    os.remove("GKExists.ini")


but check if the file exists (Not Working):
Code:

if file ~= nil
then
    messageDialog("GKTrainer Already Running!", mtError, mbOK)
else
    print('No File Exist')
end



please help me bro
Back to top
View user's profile Send private message
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1668

PostPosted: Wed Jun 05, 2019 11:52 am    Post subject: Reply with quote

You did not tell specific. You need to check a file is exist or to check if a PROCESS is open and running. But, whatever...

Code:
--#1 Check if file exists on a directory or a folder/subfolder

file = 'C:\\GKExists.ini' -- or whatever file name you need check
local f=io.open(file,"r")
if f~=nil then
print('file exist'..file)
io.close(f)
return true else
print('No File Exist')
return false end

--#2 Check if PROCESS exist or running on computer memory

-- First option
processname = "firefox.exe"
filedata = io.popen("tasklist /NH /FO CSV /FI \"IMAGENAME eq "..processname.."\"")
output = filedata:read()
filedata:close()

if output ~= "INFO: No tasks are running which match the specified criteria." then
  print(processname..' is running')
  -- os.execute("taskkill -im "..processname)
else
  -- Program is not running
  print(processname..' is not running')
end

-- Second option
processname = "firefox.exe"
local pl = getProcessList()
for pid, name in pairs(pl) do
  if name == processname then
    print('found'..name..'is running'
    break
  else print('Hei..'..name..'not found, please contact Mr.Frodo to purchase')
  end
end

_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL
Back to top
View user's profile Send private message
gavrielsinvani
Cheater
Reputation: 0

Joined: 29 May 2019
Posts: 36

PostPosted: Wed Jun 05, 2019 12:25 pm    Post subject: Reply with quote

Corroder wrote:
You did not tell specific. You need to check a file is exist or to check if a PROCESS is open and running. But, whatever...

Code:
--#1 Check if file exists on a directory or a folder/subfolder

file = 'C:\\GKExists.ini' -- or whatever file name you need check
local f=io.open(file,"r")
if f~=nil then
print('file exist'..file)
io.close(f)
return true else
print('No File Exist')
return false end

--#2 Check if PROCESS exist or running on computer memory

-- First option
processname = "firefox.exe"
filedata = io.popen("tasklist /NH /FO CSV /FI \"IMAGENAME eq "..processname.."\"")
output = filedata:read()
filedata:close()

if output ~= "INFO: No tasks are running which match the specified criteria." then
  print(processname..' is running')
  -- os.execute("taskkill -im "..processname)
else
  -- Program is not running
  print(processname..' is not running')
end

-- Second option
processname = "firefox.exe"
local pl = getProcessList()
for pid, name in pairs(pl) do
  if name == processname then
    print('found'..name..'is running'
    break
  else print('Hei..'..name..'not found, please contact Mr.Frodo to purchase')
  end
end


wow thank you for all methods,

thank you very very much !! ..
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites