Jump to content
Sign in to follow this  

Using an InputBox to edit a FileDelete Function

Recommended Posts


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

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

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

why not use

consolewrite ( envget ( "username" ) & @crlf )

consolewrite ( @UserName & @crlf )
Edited by jdelaney

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

Share this post

Link to post
Share on other sites

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
  • Like 1

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

How to get your question answered on this forum!

Share this post

Link to post
Share on other sites

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

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