Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Prompt for user name in Script 1

Status
Not open for further replies.
Sep 12, 2006
111
US
This has nothing to do with Authentication so I hope someone can help me here.

I need to delete folders that are located within a user profile in XP. Since I am logging onto the workstation with a different account I want to create a script that will prompt me for the users name so it knows what folders to delete in that users profile.

The folder paths are:

C:\Documents and Settings\%username%\Application Data\Autodesk

C:\Documents and Settings\%username%\Local Settings\Application Data\Autodesk

Can someone provide s step-by-step on how to create vb script for this type of action.
 
You can try this - but you will need to be sure you know the exact username for the profile you wish to delete the files and enter it exactly as it shows in Windows (ie. "user.domain" or just "user")

------------------------------------

Set objFSO = CreateObject ("Scripting.FileSystemObject")
Set WshShell = WScript.CreateObject("WScript.Shell")

Dim strUser, strDelFol1, strDelFol2

strUser = InputBox ("Please Enter the User Name")
If strUser = "" Then
WScript.Quit
Else
End If

strDelFol1 = "C:\Documents and Settings\" & strUser & "\Application Data\"
strDelFol2 = "C:\Documents and Settings\" & strUser & "\Local Settings\Application Data\"

If objFSO.FolderExists (strDelFol1 & "Autodesk") Then
objFSO.DeleteFolder strDelFol1 & "Autodesk", Force
Else
End If

If objFSO.FolderExists (strDelFol2 & "Autodesk") Then
objFSO.DeleteFolder strDelFol2 & "Autodesk", Force
Else
End If

WScript.Echo "Folders Removed"

Set objFSO = Nothing
Set WshShell = Nothing

------------------------------------

I hope this helps.

Pellet
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top