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 to get desktop path?

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
Y.A.K.E
Advanced Cheater
Reputation: 0

Joined: 15 Jul 2019
Posts: 56

PostPosted: Tue Sep 10, 2024 9:00 am    Post subject: how to get desktop path? Reply with quote

my desktop path is D:\xjw11\Desktop\

Code:

local path = os.getenv("USERPROFILE")
return path


return:
1:C:\Users\xjw11


Code:

local path = os.getenv("HOMEPATH")
return path

return:
1:\Users\xjw11



Screenshot 2024-09-10 225354.png
 Description:
 Filesize:  27.42 KB
 Viewed:  3173 Time(s)

Screenshot 2024-09-10 225354.png


Back to top
View user's profile Send private message
LeFiXER
Grandmaster Cheater Supreme
Reputation: 20

Joined: 02 Sep 2011
Posts: 1069
Location: 0x90

PostPosted: Tue Sep 10, 2024 5:26 pm    Post subject: Reply with quote

You can specify the letter yourself.
Code:

local driveLetter = 'D:'
local homePath = os.getenv("HOMEPATH")
local desktopPath = homePath .. '\\Desktop'

print('Desktop path: ' .. driveLetter .. desktopPath)


Or if you want a more concise version:
Code:

return 'D:' .. os.getenv("HOMEPATH") .. '\\Desktop'


Another option is utilising Powershell to retrieve the property for you:
Code:

local pipe = io.popen('powershell -command \"[Environment]::GetFolderPath(\'Desktop\')\"')
if pipe == nil then error('Something went wrong, invalid command or nil result.') end
local p = pipe:read('*all')
pipe:close()
print(p)
Back to top
View user's profile Send private message
Y.A.K.E
Advanced Cheater
Reputation: 0

Joined: 15 Jul 2019
Posts: 56

PostPosted: Tue Sep 10, 2024 10:11 pm    Post subject: Reply with quote

Quote:

local pipe = io.popen('powershell -command \"[Environment]::GetFolderPath(\'Desktop\')\"')
if pipe == nil then error('Something went wrong, invalid command or nil result.') end
local p = pipe:read('*all')
pipe:close()
print(p)


yes,is working. thank you.
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