Systemvariable in VBscript integrieren
Hallo. Ich möchte mit folgendem Script beim Login eines Users einen Ordner in seinem Profil löschen. Dies möchte ich mit der %Username% Variable im Dateipfad tun. Ich schaffe es nicht dieses Objekt in meinen Script zu integrieren. Kann mir da mal einer unter die Arme greifen? Danke!
set WshShell = WScript.CreateObject("WScript.Shell")
UserName = WshShell.ExpandEnvironmentStrings("%Username%")
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
Delete C:\Documents and Settings\%Username%\Application Data\Programm\Ordner\Cache
Wscript.Quit
Sub Delete( Strfolder)
On Error Resume Next
Dim Folder
Set Folder = fso.GetFolder(StrFolder)
For Each SubFolder in Folder.SubFolders
Delete SubFolder
If Folder.Attributes And 1 Then
Folder.Attributes = Folder.Attributes - 1
end if
SubFolder.Delete
Next
For Each File in Folder.Files
If File.Attributes And 1 Then
File.Attributes = File.Attributes - 1
End If
File.Delete
Next
End Sub
set WshShell = WScript.CreateObject("WScript.Shell")
UserName = WshShell.ExpandEnvironmentStrings("%Username%")
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
Delete C:\Documents and Settings\%Username%\Application Data\Programm\Ordner\Cache
Wscript.Quit
Sub Delete( Strfolder)
On Error Resume Next
Dim Folder
Set Folder = fso.GetFolder(StrFolder)
For Each SubFolder in Folder.SubFolders
Delete SubFolder
If Folder.Attributes And 1 Then
Folder.Attributes = Folder.Attributes - 1
end if
SubFolder.Delete
Next
For Each File in Folder.Files
If File.Attributes And 1 Then
File.Attributes = File.Attributes - 1
End If
File.Delete
Next
End Sub
Please also mark the comments that contributed to the solution of the article
Content-Key: 144185
Url: https://administrator.de/contentid/144185
Printed on: April 24, 2024 at 22:04 o'clock
6 Comments
Latest comment