$ShortCut = $Shell.CreateShortcut($MS_target_dir + "IBM Lotus Notes.lnk") $Shell = New-Object -ComObject ("WScript.Shell") New-Item -ItemType Directory -Path $MS_target_dir -Force | Out-Null $MS_target_dir="C:\ProgramData\Microsoft\Windows\Start Menu\Programs\IBM Applications\" If (Test-Path "C:\Program Files (x86)\IBM\Lotus\Notes\notes.exe" -PathType Leaf) #check if LN 8 is installed - if yes make shortcut add the trailing line with only 4 spaces.
paste the code into the reddit text box.add the leading line with only 4 spaces.the 12th from the left, & looks like an uppercase T in the upper left corner of a square.] less simple = use reddit code formatting. Please remember to set the file/code type on Pastebin! otherwise you don't get the nice code colorization. simplest = post it to a text site like or and then post the link here.
this does NOT line wrap & does NOT side-scroll on !] that's the upper left key on an EN-US keyboard layout.
Reddit likes to mangle code formatting, so here's some help on how to post code on reddit. I've googled this error, it's one of those nasty, imprecise, 'developers put that error in lots of places' kind of error. Value does not fall within the expected range. TL DR when I try and use PowerShell to create my shortcut using WScript.Shell and define my big long nasty runas.exe string and a path to my executable, the code bombs with: It's something myself and others in IT have done for years, we usually create these shortcuts manually and even though they're not tough to create, I'm trying to automate everything in sight. I'm trying to author a shortcut that calls the 'RunAs' utility and defines which account to use to run the program I'm creating a shortcut to. except it's not working for me at the moment. I'd like to use PowerShell to author Windows shortcut *.lnk files.I've been using the example of others I found online which involves using WScript.Shell and then using it's 'CreateShortcut' method, defining a TargetPath, a ShortcutIcon, a location to store the shortcut itself. The subsequent arguments you provide to RunAs, including the path to the program you want to run, are stored in the Target Arguments field. Research Triangle Powershell User Group remote-capableĪ shortcut that involves the 'RunAs' tool is a little different in that, instead of the program you wanting to run being the 'target' of that shortcut, RunAs itself is now the target.Philadelphia PowerShell User Group remote-capable.Madison Power Users Group remote-capable.Denver Microsoft Enterprise Management User Group.NET, POSH is a full-featured task automation framework for distributed Microsoft platforms and solutions. Windows PowerShell (POSH) is a command-line shell and associated scripting language created by Microsoft. Submission Guidelines | Link Flair - How To