Creating a start-up item

I am still very new to Powershell and using Automox with Powershell and was wondering what would be needed to create a worklet that would create a start-up item.

This is for a Papercut printing client that is run from a network share.

I would mean avoiding a mass manual install so would be very useful!

Sorry if this is not the right place for this.

Thanks!

1 Like

I did that in this worklet:

It makes a startup shortcut that points to an executable, so you could take that portion of the code. Let me know if you need assistance getting your worklet running!

1 Like

Completely glanced over that! Maybe i need to get another eye test…

In my Environment it is a little different.

I have a .Lnk file on a network share that needs to be copied to the startup location on the local machine.

Do I follow the above and replace the bginfo.exe location to reference my .Lnk location?

If i run

$source="\\server\Software\Papercut shortcut\PC-Client.lnk"

$destination="C:\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp"

Copy-item -path $source -destination $destination -force

on the local machine it copies the file without a problem, I am just struggling to get Automox to do this.

Thanks

So the issue you have there is Automox is most likely running as SYSTEM.
That would mean it probably doesn’t have READ access to your SMB Share on \server.
You would either need to upload the PC-Client.lnk into the worklet or create it on the fly with more powershell. Like below.

# Create a Shortcut with Windows PowerShell

$SourceFileLocation = "$env:SystemRoot\System32\notepad.exe"

$ShortcutLocation = "C:\Users\thiyagu.a.selvaraj\Desktop\Notepad.lnk"

#New-Object : Creates an instance of a Microsoft .NET Framework or COM object.

#-ComObject WScript.Shell: This creates an instance of the COM object that represents the WScript.Shell for invoke CreateShortCut

$WScriptShell = New-Object -ComObject WScript.Shell

$Shortcut = $WScriptShell.CreateShortcut($ShortcutLocation)

$Shortcut.TargetPath = $SourceFileLocation

#Save the Shortcut to the TargetPath

$Shortcut.Save()
1 Like

That worked a treat! I was looking at it from completely the wrong angle. Thanks @MinnesotaJoe and @Nic!

1 Like

@MinnesotaJoe is correct - worklets run as System so they don’t have any network shares, permissions or variables that you’d have logged in as you. It’s not advisable to put credentials into a worklet, so Joe’s approach is best in this situation.

1 Like