Quantcast
Channel: Spiceworks Community
Viewing all articles
Browse latest Browse all 6732

VB Script how to set %userprofile% or %username%

$
0
0

Hello,

How can I set the User Profile or User Name variable in a vbs file?

On logon I want to delete the users My Documents folder.

I found this on the internet and it works... I just have to figure out how to set the user variable.. so in the area bolded below I can write something like %username%

Dim objFSO, objFolder, objSubFolder, objFile
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder("C:\Users\myprofile\Documents")
'Delete each file in root folder
For Each objFile In objFolder.Files
objFSO.DeleteFile objFile.Path,True
Next
'delete each subfolder and their contents in root folder
For Each objSubFolder In objFolder.SubFolders
objFSO.DeleteFolder objSubFolder.Path,True
Next
Set objFolder = Nothing
Set objFSO = Nothing


Viewing all articles
Browse latest Browse all 6732

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>