Share via


Exception calling "Save" with "0" arguments

Question

Tuesday, April 26, 2016 8:41 PM

I am attempting to create a shortcut using the following

Set-Content -Path "$($InstallDirectory)\rdpConnection.rdp"

$objShell = New-Object -ComObject WScript.Shell
$lnk = $objShell.CreateShortcut("$($StartMenuPath)\($ShortcutName)")

$lnk.TargetPath = "%windir%\system32\mstsc.exe"
$lnk.Arguments = "/s $InstallDirectory\rdpConnection.rdp"
$lnk.Save()

The rdpConnection.rdp has been previously saved to c:\BackOffice\ but the last portion of the script (above) is not creating the shortcut to the specified directory C:\ProgramData\Microsoft\Windows\Start Menu\

I receive the error "Exception calling "Save: with "0" argument(s): Unable to save shortcut "C:\ProgramData\Microsoft\Windows\Start Menu\rdpConnection.lnk"."

DHeinz

All replies (3)

Wednesday, April 27, 2016 8:16 AM ✅Answered

Hi DRHeinz,
I would suggest you test the both paths using Test-Path to see if they are valid. Then please check the account permission you are using to see if it is allowed to access paths and create shortcut.

Alternatively, if you want to create shortcut, you could have a try using group policy. Shortcut preference items in group policy allow you to configure a shortcut to a file system object (such as a file, folder, drive, share, or computer), a shell object (such as a printer, desktop item, or control panel item), or a URL (such as a Web page or an FTP site). Please see details from: https://technet.microsoft.com/en-us/library/cc753580.aspx?f=255&MSPPError=-2147217396

Regards,
Wendy

Please remember to mark the replies as answers if they help and un-mark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact [email protected].


Wednesday, April 27, 2016 1:58 AM

Dear Sir,

Thank you for posting here in ConfigMgr Forum.

After reading through your question, it seems that it's more like PowerShell question. I'll move the thread to PowerShell forum in below link:

https://social.technet.microsoft.com/Forums/office/en-US/home?forum=winserverpowershell

You will get better and quicker answer. Thanks for understanding.

Best regards

Frank

Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact [email protected]


Wednesday, April 27, 2016 2:14 AM

It is not possible to decode your question.  Can you please state it in simple terms?

\(ツ)_/