0

anyone could help this out? Its about powershell use. Im using inside after effects scripting language: extendscript.

Pinning works, but cant solve unpinning; Tried this and many other ways, before posting.

// Pin folder to quick access (working)
    system.callSystem("cmd.exe /c powershell.exe -c \"$qa = New-Object -ComObject shell.application; $qa.NameSpace('C:\\TEST').Self.InvokeVerb(\'pintohome\')\"");

// Unpin folder from quick access (not working):
    system.callSystem("cmd.exe /c powershell.exe -c \"($qa.Namespace(\"shell:::{679F85CB-0220-4080-B29B-5540CC05AAB6}\").Items() | Where-Object { $_.Path -EQ 'C:\\TEST' }).InvokeVerb('unpinfromhome')\"");

Tried to follow this post instructions.

1 Answers1

0

Your unpin call doesnt define $qa - each execution of system.callSystem() is starting a new PowerShell instance which is independent. On your attempt to unpin $qa will be undefined / Namespace() wont exist and it will fail.

Try copying the code $qa = New-Object -ComObject shell.application; from the beginning of the pin command and paste it at the beginning of the unpin command like this:

system.callSystem("cmd.exe /c powershell.exe -c \"$qa = New-Object -ComObject shell.application; ($qa.Namespace(\"shell:::{679F85CB-0220-4080-B29B-5540CC05AAB6}\").Items() | Where-Object { $_.Path -EQ 'C:\\TEST' }).InvokeVerb('unpinfromhome')\"");
MisterSmith
  • 2,884
  • 1
  • 10
  • 13
  • thanks for answering. this code works in powershell: `$qa = New-Object -ComObject shell.application;($qa.Namespace("shell:::{679F85CB-0220-4080-B29B-5540CC05AAB6}").Items() | Where-Object { $_.Path -EQ 'C:\TEST' }).InvokeVerb("unpinfromhome")` But this one u sent, didnt. Nothing happens. `system.callSystem("cmd.exe /c powershell.exe -c \"$qa = New-Object -ComObject shell.application; ($qa.Namespace(\"shell:::{679F85CB-0220-4080-B29B-5540CC05AAB6}\").Items() | Where-Object { $_.Path -EQ 'C:\\TEST' }).InvokeVerb('unpinfromhome')\"");` – rodrigotrovao Sep 08 '21 at 21:13
  • It must be throwing some runtime error - try adding `Start-Transcript -Path scriptlog.txt;` to the start of the powershell command. That will write all output and errors to the file `scriptlog.txt` - maybe something useful there? (you can edit your question and add more info to the bottom ;-)) – MisterSmith Sep 08 '21 at 21:39
  • tried some configs and didnt work for me yet – rodrigotrovao Oct 01 '21 at 12:32