BrokenThumb Posted November 16, 2012 Share Posted November 16, 2012 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. Link to comment Share on other sites More sharing options...
jdelaney Posted November 16, 2012 Share Posted November 16, 2012 (edited) why not use consolewrite ( envget ( "username" ) & @crlf ) OR consolewrite ( @UserName & @crlf ) Edited November 16, 2012 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. Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted November 16, 2012 Moderators Share Posted November 16, 2012 (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 November 16, 2012 by JLogan3o13 BrokenThumb 1 "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! Link to comment Share on other sites More sharing options...
BrokenThumb Posted November 16, 2012 Author Share Posted November 16, 2012 (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 November 16, 2012 by SilasMontgommeri Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted November 16, 2012 Moderators Share Posted November 16, 2012 The macros are global within AutoIt, so you can use them anywhere in your script "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! Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now