Video Screencast Help
Search Video Help Close Back
to help
Not able to make it to Vision this year? Get a sampling in the Best of Vision on Demand group.

Delete folder under Doc & Setting for all users

Updated: 21 May 2010 | 5 comments
fkish's picture
0 0 Votes
Login to vote

Hi

I think this is the correct forum, I'm using Wise Installation System 9.

I need to loop thru all the existing users under Doc and Setting and remove a specific folder.

How can I do this?

F

Comments

EdT's picture
09
Oct
2009
0 Votes 0
Login to vote

No elegant solution, but it can be done

There is no elegant solution to this, but it can be done.
What you need to do is to create a file containing all the folders under documents and settings
So you would use the Execute Program command to run something like this:

%SYS32%\cmd.exe /c dir /b /s "C:\Documents and Settings" > %TEMP%\dirlist.txt

(where %SYS%\cmd.exe is the "executable" and the rest of the line goes into the "argument" box )

Once you have the listing of all folders under docs and settings, you can use the "Read/Update text file" command to read through this file one line at a time until you find what you are looking for. Since the Read/update command is effectively a looping command, you can include a delete command in the loop, to run whenever your test parameters return true.

Your final code should delete the temp file you created to tidy up.

If your issue has been solved, please use the "Mark as Solution" link on the most relevant thread.

Sushma's picture
09
Oct
2009
0 Votes 0
Login to vote

You can do this using a

You can do this using a vbscript.

Eshwar has gone for a vbscript using which we can copy files from all the user profiles to destination. You can change the script accordingly so that the script will delete a particular folder if exists. Here is the link:

https://www-secure.symantec.com/connect/downloads/backing-user-profiles-using-vbscript

Greetings,
Sushma

EdT's picture
09
Oct
2009
0 Votes 0
Login to vote

VBScript support

Wise Installation System 9 does not have native support for VBScript - this was only introduced in the Wisescript Editors shipping with Wise Package Studio 7 and Wise Installation Studio 7.

However, you can certainly use a vbscript to make the necessary folder deletions, and call it using the "Execute Program" command, by calling wscript.exe or cscript.exe as the "executable" and passing the full filename and path of the vbs file as the command argument.

If your issue has been solved, please use the "Mark as Solution" link on the most relevant thread.

michaelnowell's picture
09
Oct
2009
0 Votes 0
Login to vote

Here's a wisescript that will do what you want.

This script will look in the registry for all local profiles on the PC and then searches for the folder "C:\Documents and Settings\$Usernames$\Application Data\ICAClient".  Just modify the script for the desired location.

Document Type: WSE
item: Global
  Version=9.02
  Flags=00000100
  Languages=65 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
  Copy Default=1
  Japanese Font Name=MS Gothic
  Japanese Font Size=9
  Start Gradient=0 0 255
  End Gradient=0 0 0
  Windows Flags=00000100000000000011110000000110
  Message Font=MS Sans Serif
  Font Size=8
  Pages Modified=00101000001000000000000000000000
  Disk Filename=SETUP
  Patch Flags=0000000000000001
  Patch Threshold=85
  Patch Memory=4000
  MIF PDF Version=1.0
  MIF SMS Version=2.0
  FTP Cluster Size=20
  Per-User Version ID=1
  Dialogs Version=9
  Crystal Format=10111100101100000010001001001001
  Crystal Destination=00000000000000000000000000001011
  WamDB Index=\\calfas1\WiseSharePoint\
  Step View=&Properties
  Variable Name1=_INIT_WINDOW_
  Variable Default1=HIDE
  Variable Flags1=00001000
  Variable Name2=_SYS_
  Variable Default2=C:\Windows\system32
  Variable Flags2=00001000
  Variable Name3=_WIN_
  Variable Default3=C:\Windows
  Variable Flags3=00001000
  Variable Name4=_WISE_
  Variable Default4=\\calfas1\DesktopAdmin\Wise Packaging Studio\WiseScript Editor
  Variable Flags4=00001000
end
item: Set Variable
  Variable=DOCUMENTSANDSETTINGS
  Value=C:\Documents and Settings
end
item: Get Environment Variable
  Variable=USERNAME
  Environment=USERNAME
end
item: Remark
end
item: Remark
end
item: Remark
  Text=THis will search in the local profiles for the ICAClient folder and if it exists, it will be deleted.
end
item: Remark
end
item: Set Variable
  Variable=NEXTITEM
end
item: Set Variable
  Variable=NEXTITEM B
end
item: Set Variable
  Variable=NEXTDATA
end
item: Set Variable
  Variable=INDEX
  Value=0
end
item: Set Variable
  Variable=INDEX B
  Value=0
end
item: Set Variable
  Variable=ROOTKEY
  Value=HKEY_LOCAL_MACHINE
end
item: Set Variable
  Variable=SUBKEY
  Value=SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList
end
item: Set Variable
  Variable=NAMES
end
item: Custom Script Item
  Filename=Get Registry Keys or Values.wse
  Variable Name1=_KEYORVALUE_
  Variable Value1=A
  Variable Name2=_NEXTNAME_
  Variable Value2=NEXTITEM
  Variable Name3=_KEYPATH_
  Variable Value3=%SUBKEY%
  Variable Name4=_KEYROOT_
  Variable Value4=%ROOTKEY%
  Variable Name5=_INDEX_
  Variable Value5=%INDEX%
end
item: If/While Statement
  Variable=NEXTITEM
  Flags=00010001
end
item: Set Variable
  Variable=NAMES
  Value=%NEXTITEM%
end
item: Set Variable
  Variable=KEY
  Value=%SUBKEY%\%NAMES%
end
item: Set Variable
  Variable=NEXTITEM B
  Value=%NEXTITEM%
end
item: Set Variable
  Variable=INDEX B
  Value=%INDEX%
end
item: Set Variable
  Variable=INDEX
  Value=0
end
item: If/While Statement
  Variable=NEXTITEM
  Flags=00010001
end
item: Custom Script Item
  Filename=Get Registry Keys or Values.wse
  Variable Name1=_KEYORVALUE_
  Variable Value1=B
  Variable Name2=_NEXTNAME_
  Variable Value2=NEXTITEM
  Variable Name3=_KEYPATH_
  Variable Value3=%KEY%
  Variable Name4=_KEYROOT_
  Variable Value4=%ROOTKEY%
  Variable Name5=_INDEX_
  Variable Value5=%INDEX%
end
item: Get Registry Key Value
  Variable=NEXTDATA
  Key=%KEY%
  Default=***Failed***
  Value Name=%NEXTITEM%
  Flags=00010100
end
item: If/While Statement
  Variable=NEXTDATA
  Value=Documents and Settings
  Flags=00000010
end
item: Set Variable
  Variable=USERNAME
  Value=After$(NEXTDATA,"Documents and Settings\")
  Flags=00100000
end
item: Remark
end
item: Check if File/Dir Exists
  Pathname=%DOCUMENTSANDSETTINGS%\%USERNAME%\Application Data\ICAClient
  Flags=01000101
end
item: Delete File
  Pathname=%DOCUMENTSANDSETTINGS%\%USERNAME%\Application Data\ICAClient\*
  Flags=00001100
end
item: End Block
end
item: End Block
end
item: Set Variable
  Variable=INDEX
  Value=%INDEX%
  Flags=00000100
end
item: End Block
end
item: Set Variable
  Variable=NEXTITEM
  Value=%NEXTITEM B%
end
item: Set Variable
  Variable=INDEX
  Value=%INDEX B%
end
item: Remark
end
item: Remark
end
item: Set Variable
  Variable=INDEX
  Value=%INDEX%
  Flags=00000100
end
item: Set Variable
  Variable=NEXTITEM
end
item: Custom Script Item
  Filename=Get Registry Keys or Values.wse
  Variable Name1=_KEYORVALUE_
  Variable Value1=A
  Variable Name2=_NEXTNAME_
  Variable Value2=NEXTITEM
  Variable Name3=_KEYPATH_
  Variable Value3=%SUBKEY%
  Variable Name4=_KEYROOT_
  Variable Value4=%ROOTKEY%
  Variable Name5=_INDEX_
  Variable Value5=%INDEX%
end
item: End Block
end
item: Remark
end
item: Remark
end
item: Remark
end
item: Remark
end
item: Display Message
  Title=END
  Text=Complete
end
EdT's picture
12
Oct
2009
0 Votes 0
Login to vote

Local or Roaming profiles?

Nice script Michael....

fkish - Now would be a good time to check whether your environment uses local or roaming profiles, or a mix of both ?

If your issue has been solved, please use the "Mark as Solution" link on the most relevant thread.