I have a shutdown script which erases the entire data from the drive which I'm applying on machine through group policy as a shutdown script. When I run the script manually it works fine, but when I try applying it through group policy it doesn't work.
Suggest the measures or mistake.
The script is as follows:
On Error Resume Next
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objShell = CreateObject("Wscript.Shell")
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!" & strComputer & "\root\cimv2" )
Dim sSysDrive : sSysDrive = CreateObject( "Scripting.FileSystemObject" ) _
.GetDriveName( _
CreateObject( "WScript.Shell" ).Environment( "PROCESS" )( "SYSTEMROOT" ) )
Dim colDisks
Set colDisks = objWMIService.ExecQuery("Select * from Win32_LogicalDisk")
Dim drives : drives = ""
Dim objDisk
For Each objDisk in colDisks
If objDisk.DriveType = 3 _
And objDisk.DeviceID <> sSysDrive Then
If drives > "" Then
drives = drives & ";"
End If
drives = objDisk.DeviceID & "\"
If (drives="Q:\") then
'Do nothing
Else
temp=drives
End If
End if
Next
objshell.Run("cmd /c echo y|del "&temp&"* /Q /S")
Set objFoldersC = objFSO.GetFolder(temp)
Dim count : count= objFoldersC.subfolders.count
for i=0 to count
For Each folder in objFoldersC.SubFolders
var= temp & folder.name
var1 =temp & "\A"
objFSO.MoveFolder var, var1
objShell.Run("cmd /c echo y|rmdir "&temp&"\A /s /q")
Next
Next
Thanks in advance.