+ Post New Thread
Page 2 of 2 FirstFirst 12
Results 16 to 29 of 29
Scripts Thread, Delete Files Older Than x Days - ForFiles.exe - Script Issues in Coding and Web Development; Originally Posted by creese Just had a thought..... you do have forfiles.exe on your system? EDIT: If not you can ...
  1. #16
    gtg93's Avatar
    Join Date
    May 2010
    Posts
    306
    Thank Post
    176
    Thanked 40 Times in 32 Posts
    Rep Power
    15
    Quote Originally Posted by creese View Post
    Just had a thought..... you do have forfiles.exe on your system?

    EDIT:

    If not you can download it from here: http://www.ipass.net/davesisk/oont_download_forfiles.htm
    Tried it with this version and - same results as before.


    One thing to keep in mind with your forfiles command is that it will delete the files regardless of whether there are new ones to take their place. For example, say there was an issue with your CCTV system and it didn't record anything for an entire week, you would end up with a completely empty Channel1 folder because all of the files are older than five days.

    The VBScript below attempts to solve this problem by making sure that there are always five days worth of files kept, even if some of the files are actually older than five days (hopefully that makes sense?).


    Code:
    ...
    Tried that too and I get a windows popup like the one shown below as an attachment, for each file I've got in the folder (and there's 8109 - not good ) and nothing happens after that.
    I haven't changed anything within the script, was I supposed to? I had a look through and couldn't really see anything to change but then again I've not really had any experience with VBS.
    I realised the filepath but that's fine.

    Thanks again to all of you
    Attached Images Attached Images

  2. #17

    mac_shinobi's Avatar
    Join Date
    Aug 2005
    Posts
    9,708
    Thank Post
    3,245
    Thanked 1,048 Times in 970 Posts
    Rep Power
    364
    If Arthur does not reply I can have a look at this later on - I would use a different script that just does what you requested - although was thinking we could make it 6 days ??

  3. #18
    gtg93's Avatar
    Join Date
    May 2010
    Posts
    306
    Thank Post
    176
    Thanked 40 Times in 32 Posts
    Rep Power
    15

    Lightbulb

    Quote Originally Posted by gtg93 View Post
    Tried that too and I get a windows popup like the one shown below as an attachment, for each file I've got in the folder (and there's 8109 - not good ) and nothing happens after that.
    Ignore that - We have success - Although there was two popups for each file :/ the one shown above then one that was the same as that but it said "successfully deleted" at the end. I've linked a screenshot below. Now that script is brill, it does the job but is there anyway I can remove the popups? I assume it'll just be a matter of changing a 1 to a 0 or true to a false or something?

    The problem is that the machine is only used for CCTV so if it needs accessing I don't want to have to sit through 10000+ popups from each time the script has run.

    Those 8000 files I mentioned before was only from 10 days of recording!!

    Quote Originally Posted by mac_shinobi View Post
    If Arthur does not reply I can have a look at this later on - I would use a different script that just does what you requested - although was thinking we could make it 6 days ??
    If you have a script more suited to the task then I would be extremely greatful to see it, and yes, 6 days isn't a problem, I can just alter how often the script will be run.
    Attached Images Attached Images

  4. #19


    Join Date
    Feb 2007
    Location
    51.405546, -0.510212
    Posts
    8,758
    Thank Post
    221
    Thanked 2,630 Times in 1,938 Posts
    Rep Power
    779
    Quote Originally Posted by gtg93 View Post
    Tried that too and I get a windows popup like the one shown below as an attachment, for each file I've got in the folder (and there's 8109 - not good ) and nothing happens after that.
    I forgot to mention that you need to run it using "cscript" to avoid those popups. One way to do this would be to create a batch file which in turn runs the VBScript.

    Code:
    cscript DeleteX.vbs
    The log file should look something like this once it has been run...

    Code:
    ------------------------------------------------------------------
    Run time: 12/01/2011 08:17:19
    Most Recent Backup File dated: 03/01/2011 00:17:01, 9 day(s) ago.
    11/01/2011: No Backup Found!!
    10/01/2011: No Backup Found!!
    09/01/2011: No Backup Found!!
    08/01/2011: No Backup Found!!
    07/01/2011: No Backup Found!!
    06/01/2011: No Backup Found!!
    05/01/2011: No Backup Found!!
    04/01/2011: No Backup Found!!
    03/01/2011: 	example.wmv
    Newest File: example.wmv - Modified: 03/01/2011 00:17:01
    02/01/2011: No Backup Found!!
    01/01/2011: No Backup Found!!
    31/12/2010: No Backup Found!!
    30/12/2010: No Backup Found!!
    29/12/2010: No Backup Found!!
    28/12/2010: No Backup Found!!
    27/12/2010: No Backup Found!!
    26/12/2010: No Backup Found!!
    25/12/2010: 	example.swf
    24/12/2010: No Backup Found!!
    23/12/2010: No Backup Found!!
    22/12/2010: No Backup Found!!
    21/12/2010: No Backup Found!!
    20/12/2010: No Backup Found!!
    19/12/2010: No Backup Found!!
    18/12/2010: No Backup Found!!
    17/12/2010: 	example.mov
    		example.iso
    		example.mts
    16/12/2010: No Backup Found!!
    15/12/2010: No Backup Found!!
    14/12/2010: 	example.avi
    13/12/2010: No Backup Found!!
    12/12/2010: No Backup Found!!
    11/12/2010: No Backup Found!!
    10/12/2010: No Backup Found!!
    09/12/2010: No Backup Found!!
    08/12/2010: No Backup Found!!
    07/12/2010: 	example.mkv
    C:\CCTV\Channel1\example.zip Deleted Successfully.
    C:\CCTV\Channel1\example.rar Deleted Successfully.
    C:\CCTV\Channel1\example.7z Deleted Successfully.
    C:\CCTV\Channel1\example.dmg Deleted Successfully.
    C:\CCTV\Channel1\example.cmd Deleted Successfully.
    C:\CCTV\Channel1\example.tmp Deleted Successfully.
    
    Successful Days: 5
    Failed Days: 31
    Deleted Files: 6
    It worked perfectly when I tested it on my computer.

  5. #20

    creese's Avatar
    Join Date
    Feb 2009
    Location
    -28 31' 48.89", +28 25' 37.42" ... if only.
    Posts
    3,253
    Thank Post
    181
    Thanked 375 Times in 304 Posts
    Rep Power
    173
    I have about 120 instances of that script running, strange it doesn't work for you.

    EDIT: I also use forfiles /p d:\Folder /s /m *.* /d -1 /c "cmd /c move @FILE d:\Folder\archive"
    Last edited by creese; 12th January 2011 at 08:54 AM.

  6. #21
    gtg93's Avatar
    Join Date
    May 2010
    Posts
    306
    Thank Post
    176
    Thanked 40 Times in 32 Posts
    Rep Power
    15
    I forgot to mention that you need to run it using "cscript" to avoid those popups. One way to do this would be to create a batch file which in turn runs the VBScript.

    Code:
    cscript DeleteX.vbs
    That works great, thanks

    Although if anyone thinks they have a better script I'll be greatful for other suggestions, I've not had much experience with scripting so it's always good to get a bit of knowledge

    I have about 120 instances of that script running, strange it doesn't work for you.
    And yes that does seem strange, especially with how many other websites I've read with more or less the same script and people reporting it works fine too.

  7. #22

    mac_shinobi's Avatar
    Join Date
    Aug 2005
    Posts
    9,708
    Thank Post
    3,245
    Thanked 1,048 Times in 970 Posts
    Rep Power
    364
    Code:
    '=============
    ' Objective: To delete old files from a given folder and all subfolders below
    ' Created Date: June 27, 2007
    ' Usage: cscript deloldfiles.vbs c:\dba\log 3 partoffilename
    '      : It deletes files older than 3 days
    strInvalidUsage = "Usage: cscript deloldfiles.vbs BaseFolder DaysOld RecurseOn [FileName]" & VbCrLf &_
            "   BaseFolder:   REQUIRED   The full path to the target folder to delete from" & VbCrLf &_
            "   DaysOld:      REQUIRED   The minimum age in days of the files to delete" & VbCrLf &_
            "   RecurseOn:    REQUIRED   Value must be YES or NO" & VbCrLf &_
            "   FileName:     OPTIONAL   The name of the file(s) to delete.  An asterix (*)" & VbCrLf &_
            "                            wilcard can be placed at either end, or both ends" & VbCrLf &_
            "                            eg, *.txt   OR   file*   OR   *sample*" & VbCrLf & VbCrLf
     
    If WScript.Arguments.Count <> 3 And WScript.Arguments.Count <> 4 Then
            WScript.Echo VbCrLf & "ERROR: Invalid amount of arguments." & VbCrLf
            WScript.Echo strInvalidUsage
            WScript.Quit
    End If
    Set objArgs = WScript.Arguments
    FolderName =objArgs(0)
    Days=objArgs(1)
    RecurseOn = objArgs(2)
    If RecurseOn <> "YES" And RecurseOn <> "NO" Then
            WScript.Echo VbCrLf & "ERROR: Invalid RecurseOn flag." & VbCrLf
            WScript.Echo strInvalidUsage
            WScript.Quit
    End If
    If WScript.Arguments.Count = 4 Then
          strPartOfFileName = objArgs(3)
    Else
          strPartOfFileName = ""
    End If
     
    set fso = createobject("scripting.filesystemobject")
    Set objFolder = fso.getfolder(FolderName)
    datetoday = now()
    newdate = dateadd("d", Days*-1, datetoday)
    wscript.echo "Today:" & now()
    wscript.echo "Started deleting files older than :" & newdate 
    wscript.echo "________________________________________________"
    wscript.echo ""
     
      set files = objFolder.files
    '  wscript.echo ""
    '  wscript.echo "Deleting Files under the Folder:" & objFolder.path
    '  wscript.echo "__________________________________________________________________________"
      for each file in files
        if file.datelastmodified < newdate Then
                If strPartOfFileName <> "" Then
                      If Left(strPartOfFileName, 1) = "*" And Right(strPartOfFileName, 1) = "*" Then
                                    'WScript.Echo "Looking for: " & LCase(Mid(strPartOfFileName, 2, Len(strPartOfFileName) - 2))
                            If InStr(LCase(file.Name), LCase(Mid(strPartOfFileName, 2, Len(strPartOfFileName) - 2))) > 0 Then
                                  wscript.echo "Deleting " & objFolder.path & "\" & file.name & " last modified: " & file.datelastmodified
                                  on error resume Next
                                  'file.delete
                            End If
                      ElseIf Left(strPartOfFileName, 1) = "*" Then
                            If LCase(Right(file.Name, Len(strPartOfFileName) - 1)) = LCase(Right(strPartOfFileName, Len(strPartOfFileName) - 1)) Then
                                  wscript.echo "Deleting " & objFolder.path & "\" & file.name & " last modified: " & file.datelastmodified
                                  on error resume Next
                                  'file.delete
                            End If                        
                      ElseIf Right(strPartOfFileName, 1) = "*" Then
                            If LCase(Left(file.Name, Len(strPartOfFileName) - 1)) = LCase(Left(strPartOfFileName, Len(strPartOfFileName) - 1)) Then
                                  wscript.echo "Deleting " & objFolder.path & "\" & file.name & " last modified: " & file.datelastmodified
                                  on error resume Next
                                  'file.delete
                            End If                        
                      End If
                Else
                      wscript.echo "Deleting " & objFolder.path & "\" & file.name & " last modified: " & file.datelastmodified
                      on Error resume Next
                      'file.delete            
                End If
        end If
      Next
            
    If UCase(RecurseOn) = "YES" Then
            recurse objFolder, strPartOfFileName
    End If
     
    wscript.echo ""
    wscript.echo "Completed deleting files older than :" & newdate 
    wscript.echo "________________________________________________"
     
    sub recurse(folders, strPartOfFileName)
      For Each subfolder In folders.subfolders
      Set objFolder = fso.GetFolder(subfolder.Path)
      set files = objFolder.files
      wscript.echo ""
      wscript.echo "Deleting Files under the Folder:" & objFolder.path
      wscript.echo "__________________________________________________________________________"
      for each file in files
        if file.datelastmodified < newdate Then
                If strPartOfFileName <> "" Then
                      If Left(strPartOfFileName, 1) = "*" And Right(strPartOfFileName, 1) = "*" Then
                                    'WScript.Echo "Looking for: " & LCase(Mid(strPartOfFileName, 2, Len(strPartOfFileName) - 2))
                            If InStr(LCase(file.Name), LCase(Mid(strPartOfFileName, 2, Len(strPartOfFileName) - 2))) > 0 Then
                                  wscript.echo "Deleting " & objFolder.path & "\" & file.name & " last modified: " & file.datelastmodified
                                  on error resume Next
                                  'file.delete
                            End If
                      ElseIf Left(strPartOfFileName, 1) = "*" Then
                            If LCase(Right(file.Name, Len(strPartOfFileName) - 1)) = LCase(Right(strPartOfFileName, Len(strPartOfFileName) - 1)) Then
                                  wscript.echo "Deleting " & objFolder.path & "\" & file.name & " last modified: " & file.datelastmodified
                                  on error resume Next
                                  'file.delete
                            End If                        
                      ElseIf Right(strPartOfFileName, 1) = "*" Then
                            If LCase(Left(file.Name, Len(strPartOfFileName) - 1)) = LCase(Left(strPartOfFileName, Len(strPartOfFileName) - 1)) Then
                                  wscript.echo "Deleting " & objFolder.path & "\" & file.name & " last modified: " & file.datelastmodified
                                  on error resume Next
                                  'file.delete
                            End If                        
                      End If
                Else
                      wscript.echo "Deleting " & objFolder.path & "\" & file.name & " last modified: " & file.datelastmodified
                      on Error resume Next
                      'file.delete            
                End If
        end If
      Next
      'If UCase(RecurseOn) = "YES" Then
            recurse subfolder, strPartOfFileName
      'End If
      next  
     
      'for each folder in subfolders
      '  recurse folder, strPartOfFileName
      'next  
     
      'set subfolders = nothing
      'set files = nothing
     
    end Sub
     
    '=========
    Try this for some wildcard usage. As an example, run this:

    cscript "C:\Temp\DeleteOldFiles.vbs" C:\temp\temp 60 YES *wan*
    pause


    The 60 is the days old to delete, the YES means it will recurse subfolders, and the *wan* is the pattern to match.

    Same as per Arthurs comment - use a batch file to run the 2 above relevant commands altering the first command to match your requirements ie how many days, the correct path where you want said files deleting from and also the YES or NO depending on if you want it to recurse sub folders and last but not least the pattern to match ( I presume this would be either the file name or the file type )

    Also the file.Delete lines need un commenting, they have been commented out for testing purposes


    Actually, looking at that, the recursion bit is commented out. Change this bit near the bottom:
    Next
    'If UCase(RecurseOn) = "YES" Then
    recurse subfolder, strPartOfFileName
    'End If
    Next

    to this
    Next
    If UCase(RecurseOn) = "YES" Then
    recurse subfolder, strPartOfFileName
    End If
    Next

    so that the recursion flag works.

    You will also need to uncomment all of the
    file.delete
    lines when you actually want to delete them.
    Original Code was from here :

    http://www.experts-exchange.com/Prog..._23173209.html
    Last edited by mac_shinobi; 12th January 2011 at 11:28 AM.

  8. Thanks to mac_shinobi from:

    gtg93 (13th January 2011)

  9. #23
    gtg93's Avatar
    Join Date
    May 2010
    Posts
    306
    Thank Post
    176
    Thanked 40 Times in 32 Posts
    Rep Power
    15
    Quote Originally Posted by mac_shinobi View Post
    Code:
    '=============
    ' Objective: To delete old files from a given folder and all subfolders below
    ' Created Date: June 27, 2007
    ' Usage: cscript deloldfiles.vbs c:\dba\log 3 partoffilename
    '      : It deletes files older than 3 days
    strInvalidUsage = "Usage: cscript deloldfiles.vbs BaseFolder DaysOld RecurseOn [FileName]" & VbCrLf &_
            "   BaseFolder:   REQUIRED   The full path to the target folder to delete from" & VbCrLf &_
            "   DaysOld:      REQUIRED   The minimum age in days of the files to delete" & VbCrLf &_
            "   RecurseOn:    REQUIRED   Value must be YES or NO" & VbCrLf &_
            "   FileName:     OPTIONAL   The name of the file(s) to delete.  An asterix (*)" & VbCrLf &_
            "                            wilcard can be placed at either end, or both ends" & VbCrLf &_
            "                            eg, *.txt   OR   file*   OR   *sample*" & VbCrLf & VbCrLf
     
    If WScript.Arguments.Count <> 3 And WScript.Arguments.Count <> 4 Then
            WScript.Echo VbCrLf & "ERROR: Invalid amount of arguments." & VbCrLf
            WScript.Echo strInvalidUsage
            WScript.Quit
    End If
    Set objArgs = WScript.Arguments
    FolderName =objArgs(0)
    Days=objArgs(1)
    RecurseOn = objArgs(2)
    If RecurseOn <> "YES" And RecurseOn <> "NO" Then
            WScript.Echo VbCrLf & "ERROR: Invalid RecurseOn flag." & VbCrLf
            WScript.Echo strInvalidUsage
            WScript.Quit
    End If
    If WScript.Arguments.Count = 4 Then
          strPartOfFileName = objArgs(3)
    Else
          strPartOfFileName = ""
    End If
     
    set fso = createobject("scripting.filesystemobject")
    Set objFolder = fso.getfolder(FolderName)
    datetoday = now()
    newdate = dateadd("d", Days*-1, datetoday)
    wscript.echo "Today:" & now()
    wscript.echo "Started deleting files older than :" & newdate 
    wscript.echo "________________________________________________"
    wscript.echo ""
     
      set files = objFolder.files
    '  wscript.echo ""
    '  wscript.echo "Deleting Files under the Folder:" & objFolder.path
    '  wscript.echo "__________________________________________________________________________"
      for each file in files
        if file.datelastmodified < newdate Then
                If strPartOfFileName <> "" Then
                      If Left(strPartOfFileName, 1) = "*" And Right(strPartOfFileName, 1) = "*" Then
                                    'WScript.Echo "Looking for: " & LCase(Mid(strPartOfFileName, 2, Len(strPartOfFileName) - 2))
                            If InStr(LCase(file.Name), LCase(Mid(strPartOfFileName, 2, Len(strPartOfFileName) - 2))) > 0 Then
                                  wscript.echo "Deleting " & objFolder.path & "\" & file.name & " last modified: " & file.datelastmodified
                                  on error resume Next
                                  'file.delete
                            End If
                      ElseIf Left(strPartOfFileName, 1) = "*" Then
                            If LCase(Right(file.Name, Len(strPartOfFileName) - 1)) = LCase(Right(strPartOfFileName, Len(strPartOfFileName) - 1)) Then
                                  wscript.echo "Deleting " & objFolder.path & "\" & file.name & " last modified: " & file.datelastmodified
                                  on error resume Next
                                  'file.delete
                            End If                        
                      ElseIf Right(strPartOfFileName, 1) = "*" Then
                            If LCase(Left(file.Name, Len(strPartOfFileName) - 1)) = LCase(Left(strPartOfFileName, Len(strPartOfFileName) - 1)) Then
                                  wscript.echo "Deleting " & objFolder.path & "\" & file.name & " last modified: " & file.datelastmodified
                                  on error resume Next
                                  'file.delete
                            End If                        
                      End If
                Else
                      wscript.echo "Deleting " & objFolder.path & "\" & file.name & " last modified: " & file.datelastmodified
                      on Error resume Next
                      'file.delete            
                End If
        end If
      Next
            
    If UCase(RecurseOn) = "YES" Then
            recurse objFolder, strPartOfFileName
    End If
     
    wscript.echo ""
    wscript.echo "Completed deleting files older than :" & newdate 
    wscript.echo "________________________________________________"
     
    sub recurse(folders, strPartOfFileName)
      For Each subfolder In folders.subfolders
      Set objFolder = fso.GetFolder(subfolder.Path)
      set files = objFolder.files
      wscript.echo ""
      wscript.echo "Deleting Files under the Folder:" & objFolder.path
      wscript.echo "__________________________________________________________________________"
      for each file in files
        if file.datelastmodified < newdate Then
                If strPartOfFileName <> "" Then
                      If Left(strPartOfFileName, 1) = "*" And Right(strPartOfFileName, 1) = "*" Then
                                    'WScript.Echo "Looking for: " & LCase(Mid(strPartOfFileName, 2, Len(strPartOfFileName) - 2))
                            If InStr(LCase(file.Name), LCase(Mid(strPartOfFileName, 2, Len(strPartOfFileName) - 2))) > 0 Then
                                  wscript.echo "Deleting " & objFolder.path & "\" & file.name & " last modified: " & file.datelastmodified
                                  on error resume Next
                                  'file.delete
                            End If
                      ElseIf Left(strPartOfFileName, 1) = "*" Then
                            If LCase(Right(file.Name, Len(strPartOfFileName) - 1)) = LCase(Right(strPartOfFileName, Len(strPartOfFileName) - 1)) Then
                                  wscript.echo "Deleting " & objFolder.path & "\" & file.name & " last modified: " & file.datelastmodified
                                  on error resume Next
                                  'file.delete
                            End If                        
                      ElseIf Right(strPartOfFileName, 1) = "*" Then
                            If LCase(Left(file.Name, Len(strPartOfFileName) - 1)) = LCase(Left(strPartOfFileName, Len(strPartOfFileName) - 1)) Then
                                  wscript.echo "Deleting " & objFolder.path & "\" & file.name & " last modified: " & file.datelastmodified
                                  on error resume Next
                                  'file.delete
                            End If                        
                      End If
                Else
                      wscript.echo "Deleting " & objFolder.path & "\" & file.name & " last modified: " & file.datelastmodified
                      on Error resume Next
                      'file.delete            
                End If
        end If
      Next
      'If UCase(RecurseOn) = "YES" Then
            recurse subfolder, strPartOfFileName
      'End If
      next  
     
      'for each folder in subfolders
      '  recurse folder, strPartOfFileName
      'next  
     
      'set subfolders = nothing
      'set files = nothing
     
    end Sub
     
    '=========
    Try this for some wildcard usage. As an example, run this:

    cscript "C:\Temp\DeleteOldFiles.vbs" C:\temp\temp 60 YES *wan*
    pause


    The 60 is the days old to delete, the YES means it will recurse subfolders, and the *wan* is the pattern to match.

    Same as per Arthurs comment - use a batch file to run the 2 above relevant commands altering the first command to match your requirements ie how many days, the correct path where you want said files deleting from and also the YES or NO depending on if you want it to recurse sub folders and last but not least the pattern to match ( I presume this would be either the file name or the file type )

    Also the file.Delete lines need un commenting, they have been commented out for testing purposes



    Original Code was from here :

    Script to delete files after X days : delete, vbscript, recursive, time

    Thanks, I'll take a look at that one when I next get chance

  10. #24


    Join Date
    Feb 2007
    Location
    51.405546, -0.510212
    Posts
    8,758
    Thank Post
    221
    Thanked 2,630 Times in 1,938 Posts
    Rep Power
    779
    Quote Originally Posted by mac_shinobi View Post
    You vbscript addict lol, only kidding.
    I really like PowerShell now. Some things are so much simpler. e.g.

    Code:
    $a = Get-ChildItem C:\CCTV\Channel1 -recurse
    foreach($x in $a)
    {
        $y = ((Get-Date) - $x.CreationTime).Days
        if ($y -gt 5 -and $x.PsISContainer -ne $True)
            {$x.Delete()}
    }
    Source: http://blogs.technet.com/b/heyscript...n-90-days.aspx

  11. 2 Thanks to Arthur:

    box_l (25th February 2011), gtg93 (13th January 2011)

  12. #25

    mac_shinobi's Avatar
    Join Date
    Aug 2005
    Posts
    9,708
    Thank Post
    3,245
    Thanked 1,048 Times in 970 Posts
    Rep Power
    364
    @gtg

    no problem - found that on a PAQ on EE and was better then what I was going to post

    @ Arthur

    Don't have as much time as I used to so syntax is a little confusing / defo different so I would have to sit down and go through it.

  13. #26

    Join Date
    Dec 2005
    Location
    Essex
    Posts
    85
    Thank Post
    7
    Thanked 5 Times in 5 Posts
    Rep Power
    18
    There is a great guide with forfiles.exe available for download here:

    JJClements.co.uk Delete files older than certain number of days

  14. Thanks to JamesC from:

    gtg93 (21st March 2011)

  15. #27
    PEO
    PEO is offline
    PEO's Avatar
    Join Date
    Oct 2007
    Posts
    2,093
    Thank Post
    457
    Thanked 150 Times in 95 Posts
    Rep Power
    71
    sorry to dig up old post but when i tried the powershell script above the powershell cmd says the execution of scripts is disabled on this system. what do I need to set first before running the script?

  16. #28

    Steve21's Avatar
    Join Date
    Feb 2011
    Location
    Swindon
    Posts
    2,689
    Thank Post
    334
    Thanked 515 Times in 483 Posts
    Rep Power
    179
    Quote Originally Posted by PEO View Post
    sorry to dig up old post but when i tried the powershell script above the powershell cmd says the execution of scripts is disabled on this system. what do I need to set first before running the script?
    Normally I find UAC is fussy with scripts, on remote shares. (As there's no "run as admin" like on exe's). If you move it to C:\ does it work?

    Or if it normally works just not with powershell check your execution policy default is powershell scripts can't run, but cmdlets can. (Restricted level)

    Steve

  17. Thanks to Steve21 from:

    PEO (23rd May 2011)

  18. #29
    PEO
    PEO is offline
    PEO's Avatar
    Join Date
    Oct 2007
    Posts
    2,093
    Thank Post
    457
    Thanked 150 Times in 95 Posts
    Rep Power
    71
    Hello, i was testing the script on my windows 7 machine. I disabled UAC and rebooted. Additionally i ended up seting the execution policy to unrestricted. it all works fine now.

    Cheers

SHARE:
+ Post New Thread
Page 2 of 2 FirstFirst 12

Similar Threads

  1. Replies: 5
    Last Post: 1st July 2014, 08:34 AM
  2. Replies: 2
    Last Post: 13th January 2011, 12:28 PM
  3. A script to delete files created by certain owners
    By Oops_my_bad in forum Scripts
    Replies: 2
    Last Post: 22nd January 2009, 11:21 PM
  4. Replies: 6
    Last Post: 26th September 2008, 03:57 PM
  5. Script to delete certain files
    By tri_94 in forum Scripts
    Replies: 9
    Last Post: 30th April 2008, 04:56 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •