1

I am trying to create a login script, or bat file to delete the folder located in the following directory. I would like the whole folder deleted with all of its contents "Juniper Networks".

This is on a terminal server -

C:\Users(username)\AppData\Roaming\Juniper Networks

I can write a script for each username, but want a script to put in the startup folder that deleted the folder of the current user each time they login.

I found this script out there, and it works with the specific users ID, but not the %username%

Set fso = CreateObject("Scripting.FileSystemObject") Set folder = fso.GetFolder("C:\Users\%username%\AppData\Roaming\Juniper Networks\Setup Client")

Dan Cole
  • 11
  • 1
  • 3
  • 2
    Have you tried using the %username% variable? – joeqwerty Jul 02 '13 at 21:20
  • I have tried %username%. – Dan Cole Jul 09 '13 at 17:16
  • you can't embed the %USERNAME% inside of VBS. You'd need to grab that when you launch the login script. say something like "cscript.exe %USERNAME%" and then grab the command line arguments in the script and parse out the username to a variable. That way you have the path you want. – MikeAWood Jul 09 '13 at 23:03
  • you could grab the username with this Set objNetwork = CreateObject("WScript.Network") then username = objNetwork.username in vbs. – MikeAWood Jul 09 '13 at 23:06

1 Answers1

2

You could do this with a one-liner logon script in a Group Policy Object. Just run cmd.exe with the command-line argument /C rd /s /q "%APPDATA%\Juniper Networks\Setup Client".

Evan Anderson
  • 141,881
  • 20
  • 196
  • 331
  • I have actually narrowed my issue down to a specific file - C:\Users\%username%\AppData\Roaming\Juniper Networks\Setup Client\JuniperSetupClient.ini – Dan Cole Jul 09 '13 at 21:16
  • Also wanted to add, this is for Terminal Server. I would most likely just put the Bat file in the All Users Statup folder. – Dan Cole Jul 09 '13 at 21:24
  • You can certainly do that. Personally, I almost always have Loopback Merge Mode enabled for Terminal Server computers and would just throw this up as a one-liner logon script (no actual file-- just these items inside the GPO's settings) on a GPO linked to an OU that applied to the Terminal Server. However works, though. – Evan Anderson Jul 09 '13 at 21:53