Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8788119
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T22:05:24+00:00 2026-06-13T22:05:24+00:00

I am trying to generate a shortcut for every printer I have on a

  • 0

I am trying to generate a shortcut for every printer I have on a print server. The idea is to be able to email these shortcuts to people and when they click on them, it automatically installs that printer for them.

I’ve populated an array from a list of printer names exported from the print server:

$list = @((get-contnet $home\dekstop\plist.txt))

I then created a method to create a shortcut:

function Make-Shortcut
{
param ([string]$dest, [string]$source)
$WshShell = New-Object -comObject Wscript.Shell
$Shortcut = $WshShell.CreateShortcut($dest)
$Shortcut.TargetPath = $Source
$Shortcut.Save()
}

The function works fine. I was able to create standard shortcuts with no problem.

This next part is where I am getting stuck:

foreach ($i in $list)
{
Make-Shortcut "C:\pshort\$i.lnk" "C:\Windows\System32\rundll32.exe 
printui.dll,PrintUIEntry /in /q /n\\printserver\$i"
}

When this runs, it does generate a shortcut with the same name as the printer for each printer on the list. However, the problem comes in at the target path. Instead of

C:\Windows\System32\rundll32.exe printui.dll,PrintUIEntry /in /q /n\\printserver\printername

it changes it to:

C:\Windows\System32\rundll32.exe printui.dll,PrintUIEntry \in \q \n\printserver\printername

The three problems with this are:

  1. It is reversing the forward slash for the parameters
  2. It is removing one of the backslashes preceding the server name
  3. It is adding quotes to both sides. I need the quotes to come off for the shortcut to work properly.

I assume this is happening because Powershell thinks I am trying to make a standard shortcut and thinks I made mistakes while typing out the path.

I have tried putting a ` in front of each forward slash hoping the escape character would prevent it from reversing it, but no luck. I also tried using a hyphen for each parameter but that did not work either.

Is there anyway to stop this from happening? Or is there perhaps a better way to try to accomplish what I am trying to do?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T22:05:25+00:00Added an answer on June 13, 2026 at 10:05 pm

    You need to add arguments to the com object

    Try adding a new param $arguments to your Make-Shortcut function and do:

    Make-Shortcut "C:\pshort\$i.lnk" "C:\Windows\System32\rundll32.exe" 
    "printui.dll,PrintUIEntry /in /q /n\\printserver\$i"
    

    add this in your function:

    $Shortcut.Arguments = $arguments
    

    So the link is created successfully … but I have no idea if it works 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to generate a report of the activities that users have done within
I have been trying to generate report as per age differences of different months
I'm trying generate a images/chart in my controller and have that image displayed in
Im trying to generate an image, and have found UIGraphicsBeginImageContext() in the Apple docs
I'm trying to generate a stacktrace in JavaScript. I have an implementation that works
Trying to generate JavaDocs for the Android lint-cli project on Mac 10.7 Keep getting
Im trying to generate a color gradient using ColdFusion. My current code below works
I trying to generate an XML document which is around 23 to 30 MB,
I'm trying to generate the following html code using cl-who: <html> <body> <div id=cnt_1></div>
Im am trying to generate interfaces of HP Quality Center OTACLien.dll using com4j. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.