How to change the permission of for script in Vista? RRS feed

  • Question

  • Hello,

    I wrote a script which can delete or rename the folders contains protected operationing system files. It run it smoothly in XP,but It will prompt error that shows permission denied in Vista.

    The script is below, Could you please tell me how can I config the vista os or do something to solve the problem?




    strComputer = "."

    Set objWMIService = GetObject("winmgmts:" _
        & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

    'delete folders

    Set colItems = objWMIService.ExecQuery("Select SystemDrive from Win32_OperatingSystem",,48)

    Dim strSystemDrive, strCSName, strFolderName(10), strName,tmpName

    For Each objItem in colItems
       strSystemDrive = objItem.SystemDrive

    Set colItems1 = objWMIService.ExecQuery("Select UserName from Win32_ComputerSystem",,48)
    For each objitem in colItems1
    strName = objitem.UserName
    tmpName = Split(strName,"\",2,1)
    strCSName = tmpName(1)

    Const DeleteReadOnly = True

    Set objFSO = CreateObject("Scripting.FileSystemObject")

    strFolderName(0) = strSystemDrive & "\Users\" & strCSName & "\AppData\Local\Temp"

    wscript.echo strFolderName(0)

       If objFSO.FolderExists(strFolderName(0)) Then
       If objFSO.FolderExists(strFolderName(0)) Then
         objFSO.MoveFolder strFolderName(0) , strFolderName(i)&Int(Now * Rnd + 1)
       end if 
       End If



    Monday, September 18, 2006 9:31 AM

All replies

  • Hi..

    Did you ever find a solution to your problem. I am sitting with the exact same problem.




    Monday, July 23, 2007 7:29 AM
  • How are you running the script? Does it work if you start it from an elevated command prompt?
    Monday, July 23, 2007 11:42 AM
  • Its in a function on my html page.

    var myActiveXObject = new ActiveXObject('Scripting.FileSystemObject');
     file = myActiveXObject.GetFile('c:\\comm.bat');

    On "myActiveXObject.CreateTextFile('c:\\comm.bat',true);" it fails. (error "Permission denied")It works fine on ie7 with xp but fails with ie7 on vista.

    Tuesday, July 24, 2007 6:43 AM
  • IE7's Protected Mode prevents website based scripts from making changes to the local machine to enhance security. You should probably review the documentation on Protected Mode and how it may affect your application. You may need to re-architect your solution or make changes to the Security Zones on machines if you wish to implement this.
    Tuesday, July 24, 2007 3:31 PM