Jump to content

Recommended Posts

Posted (edited)

i basically would like to delete everything in the programs folder of the start menu, and au3 script for it would be nice

i have been messing around but cant get it to work

Edited by ripken204

Posted (edited)

Not quite sure exactly what you want to do but why not simply a batch file that deletes the objects?

rd C:\Documents and Settings\Administrator\Start Menu\Programs /s /q

then simply recreate an empty Programs folder

md C:\Documents and Settings\Administrator\Start Menu\Programs

You could do the same thing for All Users Programs folder.

Ian

Edited by Wiener
Posted

Strange, I just tried it and it worked here .... I first tried del C:\...\.* and like you mentioned got access denied. Then I tried the rd line and it worked just fine.

Posted

even if you can't delete the folder, you could delete its contents, right?

delete everything in here:

C:\Documents and Settings\All Users\Start Menu\Programs
and
C:\Documents and Settings\<user>\Start Menu\Programs

Posted

Use this and save as Whatever.cmd:

@echo off
rd "C:\Documents and Settings\Administrator\Start Menu\Programs" /s /q
md "C:\Documents and Settings\Administrator\Start Menu\Programs"

Posted (edited)

works perfectly, thx

now ide like to make this into an au3 scrip

this is an example they give of how to use dos

RunWait(@COMSPEC & " /c Dir C:\")

i have no clue how to do it, ive tried this but no luck

RunWait(@COMSPEC & " /c rd 'C:\Documents and Settings\All Users\Start Menu\Programs' /s /q")
RunWait(@COMSPEC & " /c md 'C:\Documents and Settings\All Users\Start Menu\Programs' /s /q")

Edited by ripken204
Posted

tried this too but no luck, there are no errors coming up in au3, i have no clue why its not working

runwait(@comspec & ' /c  ' & 'rd "C:\Documents and Settings\All Users\Start Menu\Programs /s /q"')
runwait(@comspec & ' /c  ' & 'md "C:\Documents and Settings\All Users\Start Menu\Programs /s /q"')

Posted

well forget that then, im just gunna run the cmd

au3 file

RunWait(@COMSPEC & " /c Start delStartMenu.cmd")
Sleep(2000)
Send("exit")
Send("{ENTER}")
DirCopy("Start Menu",@ProgramsDir,1)

cmd file

@echo off
rd "C:\Documents and Settings\Administrator\Start Menu\Programs" /s /q
md "C:\Documents and Settings\Administrator\Start Menu\Programs"
rd "C:\Documents and Settings\All Users\Start Menu\Programs" /s /q
md "C:\Documents and Settings\All Users\Start Menu\Programs"

what this does is it deletes the start menu crap in the cmd file, then the last line of the au3 copies a folder to be the new start menu that is all organized how i like it, all for my UA

Posted (edited)

Here is a nice simple VBS script that should do what you want.

I have it set to just popup a message.

This is for XP without ServicePack 2

Red Text Are Popups that can be removed from the script

Green Text Remove The ' From Before The text to make active

Example As Active

Set objWMIService = GetObject("winmgmts: \\" & strComputer & "\root\cimv2")

Set colFolders = objWMIService.ExecQuery("Select * from Win32_Directory where Name = '" & All_Up & "'")

For Each objFolder in colFolders

errResults = objFolder.Delete

Next

Dim Act, Fso, All_Up,objWMIService

Set Act = CreateObject("Wscript.shell")

Set Fso = CreateObject("Scripting.FileSystemObject")

All_UP = Act.ExpandEnvironmentStrings("%Allusersprofile%")

strComputer = "."

If Fso.FolderExists(All_Up) Then

All_Up = Replace(All_Up, "\","\\")

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

Set colFolders = objWMIService.ExecQuery("Select * from Win32_Directory where Name = '" & All_Up & "'")

For Each objFolder in colFolders

    ' errResults = objFolder.Delete

      Act.Popup "Confirm It Was Here" & vbCrLf & objFolder.name, 5, "Confirm", 0 + 32 

Next

Else

Act.Popup "This Folder Is Missing", 5, "Error", 0 + 32

End If

This Is for XP with Service Pack 2 Installed, the above script will not

work on XP SP2. There was some changes to the WMI class

This script works I have left it with comments lines in it plus a test

Dim Act, Fso, All_Up,objWMIService

Set Act = CreateObject("Wscript.shell")

Set Fso = CreateObject("Scripting.FileSystemObject")

All_UP = Act.ExpandEnvironmentStrings("%Allusersprofile%")

strComputer = "."

'If Fso.FolderExists(All_Up) Then '''' UNCOMMENT BEFORE USING NEED TO DELETE %Allusersprofile%

'''' FOR TESTING

If Not Fso.FolderExists("C:\Test1") Then   '''' THIS LINE CAN BE REMOVED FOR TESTING ONLY

Fso.CreateFolder("C:\Test1") '''' THIS LINE CAN BE REMOVED FOR TESTING ONLY

Fso.CreateFolder("C:\Test1\Test2") '''' THIS LINE CAN BE REMOVED FOR TESTING ONLY

Fso.CreateFolder("C:\Test1\Test3") '''' THIS LINE CAN BE REMOVED FOR TESTING ONLY

Fso.CreateFolder("C:\Test1\Test4") '''' THIS LINE CAN BE REMOVED FOR TESTING ONLY

End If '''' THIS LINE CAN BE REMOVED FOR TESTING ONLY

If Fso.FolderExists("C:\Test1") Then '''' THIS LINE CAN BE REMOVED FOR TESTING ONLY

All_UP = ("C:\Test1")'''' THIS LINE CAN BE REMOVED FOR TESTING ONLY

Dim arrFolders()

intSize = 0

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

strFolderName = All_Up

Set colSubfolders = objWMIService.ExecQuery("Associators of {Win32_Directory.Name='" & strFolderName & "'} " _

        & "Where AssocClass = Win32_Subdirectory " _

            & "ResultRole = PartComponent")

ReDim Preserve arrFolders(intSize)

arrFolders(intSize) = strFolderName

intSize = intSize + 1

For Each objFolder in colSubfolders

    GetSubFolders strFolderName

Next

Sub GetSubFolders(strFolderName)

    Set colSubfolders2 = objWMIService.ExecQuery _

        ("Associators of {Win32_Directory.Name='" & strFolderName & "'} " _

            & "Where AssocClass = Win32_Subdirectory " _

                & "ResultRole = PartComponent")

    For Each objFolder2 in colSubfolders2

        strFolderName = objFolder2.Name

        ReDim Preserve arrFolders(intSize)

        arrFolders(intSize) = strFolderName

        intSize = intSize + 1

        GetSubFolders strFolderName

    Next

End Sub

For i = Ubound(arrFolders) to 0 Step -1

    strFolder = arrFolders(i)

    strFolder = Replace(strFolder, "\", "\\")

    Set colFolders = objWMIService.ExecQuery _

        ("Select * from Win32_Directory where Name = '" & strFolder & "'")

    For Each objFolder in colFolders

        errResults = objFolder.Delete

           Act.Popup "Confirm It Was Here" & vbCrLf & objFolder.name, 5, "Confirm", 0 + 32

    Next

Next

Else

Act.Popup "This Folder Is Missing", 5, "Error", 0 + 32

End If

Edited by gunsmokingman

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...