Jump to content

Recommended Posts

Posted

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.

  • Moderators
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

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

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

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...