Tech63 Posted January 14, 2014 Share Posted January 14, 2014 I will be using DirRemove Script to remove a Folder from various different users on different pc's. The folder that needs deleted is in the same location on each pc. C:Userscurrent logged-in userAppDataLocalTempFolder Is there a wild card of some sort i can insert for current logged-in user? so that for the same script will work regardless of what user is logged in. I know, newbie question. I did some searching and couldn't come up with anything, may be just a common knowledge type thing. Link to comment Share on other sites More sharing options...
Developers Jos Posted January 14, 2014 Developers Share Posted January 14, 2014 Is the script going to run with the User's credentials? If so you could use @Username. SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
jdelaney Posted January 14, 2014 Share Posted January 14, 2014 Or get the registry value HKCUvolatile environmentusername 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 January 14, 2014 Moderators Share Posted January 14, 2014 (edited) Or @UserProfileDir (are you seeing yet how many ways there are to accomplish things with AutoIt) DirRemove(@UserProfileDir & "\AppData\Local\Temp\Folder", 1) Edit: Just thinking about Jos' initial question, if you wanted to do this remotely you could do something like this (path could easily be modified for XP): $sPC = "JLVMWIN7_1" $WMI = ObjGet("winmgmts:\\" & $sPC & "\root\CIMV2") $aItems = $WMI.ExecQuery("SELECT * FROM Win32_ComputerSystem",Default,48) For $item In $aItems If $item.UserName <> "" Then $aSplit = StringSplit($item.UserName, "\") $uName = $aSplit[2] EndIf Next $sDir = "C$\Users\" & $uName & "\AppData\Local\Temp\Folder" DirRemove("\\" & $sPC & "\" & $sDir, 1) Edited January 14, 2014 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! Link to comment Share on other sites More sharing options...
Tech63 Posted January 14, 2014 Author Share Posted January 14, 2014 JLogan3o13, That did the trick, thanks! and i'll play around with the different methods mentioned as well. there is more to the script than the deletion of just 1 folder, so i'm sure ill run into something else along the way thanks again Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted January 14, 2014 Moderators Share Posted January 14, 2014 Glad you got it solved "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...
BrewManNH Posted January 14, 2014 Share Posted January 14, 2014 By the way, the environment variable %temp% always points to the user's temp folder, so you can also use this. DirRemove(EnvGet("temp") & "\Folder", 1) Just in case they've moved their temp folder from the default location or a group policy has. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
Tech63 Posted January 17, 2014 Author Share Posted January 17, 2014 DirRemove(@UserProfileDir & "\Documents\FOLDER", 1) The path to My Documents differs from XP to 7, the script works well in windows 7 but does not remove this document in XP. I tried a combination of things for xp like : DirRemove(EnvGet("userprofile") & "\MyDocuments\BlueZone", 1) The path in xp is C :Documents and Settings user name My Documents Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted January 17, 2014 Moderators Share Posted January 17, 2014 This works for me in both XP and WIN7: DirRemove(@UserProfileDir & "\My Documents\FOLDER", 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...
BrewManNH Posted January 17, 2014 Share Posted January 17, 2014 @MyDocumentsDir If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted January 17, 2014 Moderators Share Posted January 17, 2014 @MyDocumentsDir True enough, but I was focusing on the OP's use of Envget. I was mistaken anyway, what I meant to post as an example was something like this: This should run on XP or WIN7 MsgBox(0, "", EnvGet("userprofile") & "\My Documents") "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