Sign in to follow this  
Followers 0
BrokenThumb

Using an InputBox to edit a FileDelete Function

5 posts in this topic

Hey All,

Silas here again.

I've started work on another script that goes into a user's Window's profile folders and deletes a specified config file that works with one of our applications. I can get the script to work when I hard code the users name into the script, but what I'm trying to do now is use a variable and an InputBox so a user can type in their user name and delete the file if they have any issues with software. However I cant seem to get it to run right, here's what I have so far.

; Script Start

;Variables
$UsrNm = InputBox ( "Username", "Please enter your program Username.", "dfw-" ) ;Username
if @error=1 Then
Exit
Endif

FileDelete( "C:\Users\dfw-user\AppData\Roaming\Program\Folder\config.xml" )

Now this one works when I hard code their user name where "dfw-user" is. However if I try to use the variable, of course, it just does nothing because its a string and that file path doesn't exist. I've tried breaking it up in to two strings and putting & $UsrNM in-between them however just like I thought, it didn't work. Does anyone have any ideas? I tried searching around but couldn't find anything that was quite what I was looking for. I found plenty of stuff about appending the variable onto the end of a string or a message box, but nothing like this.

Share this post


Link to post
Share on other sites



#3 ·  Posted (edited)

Hi, SilasMontgommeri. Is the location of the file within the profile static? If so, check out the different macros in the help file; you may find you don't need to prompt the user at all.

FileDelete(@UserProfileDir & "AppDataRoamingProgramFolderconfig.xml")
Edited by JLogan3o13
1 person likes this

√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Woah, that's pretty sweet Jlogan.

Much easier than I thought it would be. I'll have to go through all the rest of the Macros. Thanks a ton!

So these Macros can be added onto a function even though they're not included in the syntax?

Edited by SilasMontgommeri

Share this post


Link to post
Share on other sites

The macros are global within AutoIt, so you can use them anywhere in your script :)


√-1 2^3 ∑ π, and it was delicious!

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  
Followers 0