deleting a directory

Benutzeravatar
SisterOfMercy
Beiträge: 997
Registriert: 22 Jun 2012, 19:18

deleting a directory

Beitragvon SisterOfMercy » 23 Jun 2017, 00:56

I'm trying to delete a directory in the start menu. Somehow the normal options (LinkFolder, Files) do not seem to work.
So I'm trying with Winbatch. It should work, but it doesn't.

Part of the logfile:

Code: Alles auswählen

[6] [Jun 22 23:31:20:772] [win7-settings] ~~~~~~ Looping through:  'C:\Users\Administrator', 'C:\Users\Default'
[6] [Jun 22 23:31:20:783] [win7-settings]   
[6] [Jun 22 23:31:20:783] [win7-settings]   ~~~~~~~ Start Sub ~~~~~~~  sub_uninstall_shortcuts
[5] [Jun 22 23:31:20:784] [win7-settings]   Set  $profiledir$ = "C:\Users\Administrator"
[6] [Jun 22 23:31:20:784] [win7-settings]     The value of the variable "$profiledir$" is now: "C:\Users\Administrator"
[5] [Jun 22 23:31:20:793] [win7-settings]   
[5] [Jun 22 23:31:20:793] [win7-settings]   Execution of Winbatch_uninstall_shortcuts_AllProfiles
[6] [Jun 22 23:31:20:793] [win7-settings]     Call "rd /s /q "C:\Users\Administrator\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Maintenance""
[6] [Jun 22 23:31:20:793] [win7-settings]        Waiting until the called process is finished
[6] [Jun 22 23:31:20:793] [win7-settings]     Start process elevated
[3] [Jun 22 23:31:20:795] [win7-settings]     rd /s /q "C:\Users\Administrator\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Maintenance" .... CreateProcessAsUser Error 2 (The system cannot find the file specified.\r\n)
[3] [Jun 22 23:31:20:795] [win7-settings]     Error: rd /s /q "C:\Users\Administrator\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Maintenance" .... CreateProcessAsUser Error 2 (The system cannot find the file specified.\r\n)
[6] [Jun 22 23:31:20:795] [win7-settings]     Call "rd /s /q "C:\Users\Administrator\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Games""
[6] [Jun 22 23:31:20:795] [win7-settings]        Waiting until the called process is finished
[6] [Jun 22 23:31:20:795] [win7-settings]     Start process elevated
[3] [Jun 22 23:31:20:797] [win7-settings]     rd /s /q "C:\Users\Administrator\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Games" .... CreateProcessAsUser Error 2 (The system cannot find the file specified.\r\n)
[3] [Jun 22 23:31:20:797] [win7-settings]     Error: rd /s /q "C:\Users\Administrator\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Games" .... CreateProcessAsUser Error 2 (The system cannot find the file specified.\r\n)
[6] [Jun 22 23:31:20:797] [win7-settings]   
[6] [Jun 22 23:31:20:797] [win7-settings]   ~~~~~~~ End Sub   ~~~~~~~  sub_uninstall_shortcuts
[6] [Jun 22 23:31:20:797] [win7-settings]   
[6] [Jun 22 23:31:20:804] [win7-settings]   
[6] [Jun 22 23:31:20:804] [win7-settings]   ~~~~~~~ Start Sub ~~~~~~~  sub_uninstall_shortcuts
[5] [Jun 22 23:31:20:804] [win7-settings]   Set  $profiledir$ = "C:\Users\Default"
[6] [Jun 22 23:31:20:804] [win7-settings]     The value of the variable "$profiledir$" is now: "C:\Users\Default"
[5] [Jun 22 23:31:20:811] [win7-settings]   
[5] [Jun 22 23:31:20:811] [win7-settings]   Execution of Winbatch_uninstall_shortcuts_AllProfiles
[6] [Jun 22 23:31:20:811] [win7-settings]     Call "rd /s /q "C:\Users\Default\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Maintenance""
[6] [Jun 22 23:31:20:811] [win7-settings]        Waiting until the called process is finished
[6] [Jun 22 23:31:20:812] [win7-settings]     Start process elevated
[3] [Jun 22 23:31:20:814] [win7-settings]     rd /s /q "C:\Users\Default\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Maintenance" .... CreateProcessAsUser Error 2 (The system cannot find the file specified.\r\n)
[3] [Jun 22 23:31:20:814] [win7-settings]     Error: rd /s /q "C:\Users\Default\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Maintenance" .... CreateProcessAsUser Error 2 (The system cannot find the file specified.\r\n)
[6] [Jun 22 23:31:20:814] [win7-settings]     Call "rd /s /q "C:\Users\Default\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Games""
[6] [Jun 22 23:31:20:814] [win7-settings]        Waiting until the called process is finished
[6] [Jun 22 23:31:20:814] [win7-settings]     Start process elevated
[3] [Jun 22 23:31:20:816] [win7-settings]     rd /s /q "C:\Users\Default\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Games" .... CreateProcessAsUser Error 2 (The system cannot find the file specified.\r\n)
[3] [Jun 22 23:31:20:816] [win7-settings]     Error: rd /s /q "C:\Users\Default\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Games" .... CreateProcessAsUser Error 2 (The system cannot find the file specified.\r\n)
[6] [Jun 22 23:31:20:816] [win7-settings]   
[6] [Jun 22 23:31:20:816] [win7-settings]   ~~~~~~~ End Sub   ~~~~~~~  sub_uninstall_shortcuts


Code: Alles auswählen

for $value$ in $profileslist$ do sub_uninstall_shortcuts

[sub_uninstall_shortcuts]
set $profiledir$ = "$value$"
Winbatch_uninstall_shortcuts_AllProfiles /SysNative /RunElevated

[Winbatch_uninstall_shortcuts_AllProfiles]
rd /s /q "$profiledir$\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Maintenance"
rd /s /q "$profiledir$\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Games"


The directories are still there, even with the "The system cannot find the file specified"-error.
If I copy/paste the commands from the log, they work normally.
After this log was created I executed this command, copied from the log:

Code: Alles auswählen

rd /s /q "C:\Users\Default\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Maintenance"


And the directory was gone. Why didn't it not work in the first place?

Without the /RunElevated parameter the results are almost the same, but even crappier:

Code: Alles auswählen

[3] [Jun 23 00:52:18:917] [win7-settings]     Exception in StartProcess_cp: Failed to execute rd /s /q "C:\Users\Administrator\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Games" : 2
Bitte schreiben Sie Deutsch, when I'm responding in the German-speaking part of the forum!

Benutzeravatar
n.wenselowski
uib-Team
Beiträge: 3148
Registriert: 04 Apr 2013, 12:15

Re: deleting a directory

Beitragvon n.wenselowski » 14 Jul 2017, 11:12

Hi,

could it be that this is some kind of magic path?

Also if you are running things as a login script you can access the Appdata/Roaming through the global constant %AppdataDir%.
Did you try this?


Kind regards

Niko
opsi development - uib gmbh
For productive opsi installations we recommend support contracts.