Sign in to follow this  
Followers 0
Tech63

Help with DirRemove

11 posts in this topic

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.

Share this post


Link to post
Share on other sites



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.

Share this post


Link to post
Share on other sites

#4 ·  Posted (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 by JLogan3o13

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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

Glad you got it solved :)


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

Share this post


Link to post
Share on other sites

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 Gude
How 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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

This works for me in both XP and WIN7:

DirRemove(@UserProfileDir & "\My Documents\FOLDER", 1)

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

Share this post


Link to post
Share on other sites

@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 Gude
How 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

Share this post


Link to post
Share on other sites

@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")

√-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