Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - vb script help

Reply
 
Old 11-17-2008   #1 (permalink)
Norm z


 
 

vb script help

I have a VB Script that I am running using my Group Policy Editor to
delete user profiles during logoff (running Windows XP) . The script
works fine when I am logged in as administrator, but when individual
users logoff they get an insufficient authority error message associated
with the delete line of the script. Does anyone know if there anyway
around this problem ? See script below ...

' Set up the scripting environment
Option Explicit
Const oSrc = "C:\Documents and Settings\20*"
Dim Text, Title
Dim WSH, FSO, oFolders, oFolder, oSubFolders ' Object variables
Dim oFileCount, oFolderCount, oFiles, oCount
Text = "Folders" & vbCrLf & vbCrLf
' Dialog title (inc. vanity bit)
Title = "Student Profile Deleter"

' Create Windows Scripting Host Shell object
Set WSH = WScript.CreateObject("WScript.Shell")
' Create FileSystem object to access the file system.
Set FSO = WScript.CreateObject("Scripting.FileSystemObject")

'Delete the folder (forcibly, to handle read-only attributes)
FSO.DeleteFolder oSrc,True


'Free memory used by objects
Set WSH = Nothing
Set FSO = Nothing


WScript.Quit()

Thanks in advance


*** Sent via Developersdex http://www.developersdex.com ***

My System SpecsSystem Spec
Old 11-17-2008   #2 (permalink)
Pegasus \(MVP\)


 
 

Re: vb script help


"Norm z" <baileyn@xxxxxx> wrote in message
news:ej9FkPNSJHA.1960@xxxxxx
Quote:

>I have a VB Script that I am running using my Group Policy Editor to
> delete user profiles during logoff (running Windows XP) . The script
> works fine when I am logged in as administrator, but when individual
> users logoff they get an insufficient authority error message associated
> with the delete line of the script. Does anyone know if there anyway
> around this problem ? See script below ...
>
> ' Set up the scripting environment
> Option Explicit
> Const oSrc = "C:\Documents and Settings\20*"
> Dim Text, Title
> Dim WSH, FSO, oFolders, oFolder, oSubFolders ' Object variables
> Dim oFileCount, oFolderCount, oFiles, oCount
> Text = "Folders" & vbCrLf & vbCrLf
> ' Dialog title (inc. vanity bit)
> Title = "Student Profile Deleter"
>
> ' Create Windows Scripting Host Shell object
> Set WSH = WScript.CreateObject("WScript.Shell")
> ' Create FileSystem object to access the file system.
> Set FSO = WScript.CreateObject("Scripting.FileSystemObject")
>
> 'Delete the folder (forcibly, to handle read-only attributes)
> FSO.DeleteFolder oSrc,True
>
>
> 'Free memory used by objects
> Set WSH = Nothing
> Set FSO = Nothing
>
>
> WScript.Quit()
>
> Thanks in advance
I assume it's this line that fails:
FSO.DeleteFolder oSrc,True

Attempting to delete your own profile folder while logged on is equivalent
to sawing off the branch you sit on. Windows won't let you do it and writing
a script around it makes no difference. Try doing it from Explorer or a
Command Prompt - it won't work either!

Note that profile folders are often locked until you reboot the machine.
While they are locked nobody can delete them, not even an administrator.


My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Logon Script Causing Laptops To Hang - Problems in script? VB Script
problem passing args to script 'There is no script engine for file extenstion' VB Script
Include another script, keep variables in included script? PowerShell
Script file has 'OS Handle' error when run from script PowerShell
Can you drag-n-drop a file on top of a PS script to run the script? PowerShell


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46