Ok after having gone over some of the docs and procedures for working the wshshell object I have actually come up with a solution that works and that I'll probably employ... at work.
It took me a while to realize that I can not actually set the targetpath for an
executable using /runas with the Target Location in Sys32s Powershell Folder...
Instead... I'll just set the working directory to System32, and the TargetPath to runAs.exe...
From the arguments you provide to runAs.exe it is that you provide your extended powershell .ps1 launch arguments.
Here is a sample which launches my gradient app after prompting for your microsoft password....--->
$myAppName = 'spectrumFormLauncher.ps1'
$myLinkName = 'myLink.lnk'
$myAppFolder = 'Spex'
$myIconName = 'spex.ico'
$cactName = $env:userprofile +"\documents\"+$myAppFolder
$cactName2 = $env:userprofile + "\desktop"
$SourceExeArg = "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe"
$SourceExe = "C:\Windows\System32\runAs.exe"
$myDom = $env:USERDOMAIN
$myU = $env:USERNAME
$Arg = '/profile /user:'+$myDom+"\"+$myU
$myAppZoned = '"'+$cactName+'\modules\'+$myAppName+'"'
$ArgumentsToParameters = ' "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy Bypass -WindowStyle hidden -File ' + $myAppZoned
$ArgumentsToSourceExe = $Arg + $ArgumentsToParameters
$DestinationPath = $cactName2+"\" +$myLinkName
$testShortCut = Test-Path $DestinationPath
if($testShortCut -eq $true)
{
Remove-Item -Path $DestinationPath -Confirm:$false -ErrorAction SilentlyContinue -Recurse
}
$SourceExe2 ="C:\Windows\System32\"
$iconSpot = $cactName + "\media\"+$myIconName
$WshShell = New-Object -comObject WScript.Shell
$Shortcut = $WshShell.CreateShortcut($DestinationPath)
$Shortcut.IconLocation = $iconSpot
$Shortcut.WorkingDirectory = $SourceExe2
$Shortcut.TargetPath = $SourceExe
$Shortcut.Arguments = $ArgumentsToSourceExe
$Shortcut.Save()
Spex the Gradient App
Where I'm at in the c++ procedure
// TODO: Place code here.
//HRESULT CreateLink(LPCWSTR lpszPathObj, LPCSTR lpszPathLink, LPCWSTR lpszDesc)
// HRESULT ResolveIt(HWND hwnd, LPCSTR lpszLinkFile, LPWSTR lpszPath, int iPathBufferSize)
const wchar_t *lpszPathObj = L"C:\\users\\zero8\\desktop\\go.lnk";
const char *lpszpathLink = "powershell.exe";
const wchar_t *lpszDesc = L"whatever";
CreateLink(lpszPathObj, lpszpathLink, lpszDesc);

