I'm writing my first powershell script and I'm having a little trouble.
Up to this point my system creates a directory tree and populates it with files. The final step is to put a shortcut on my desktop.
I've come up with the code below:
$ShortcutFile = "$home\Desktop\" + $protocol + ".lnk"
If ( (test-path -path "$ShortcutFile") -ne $true)
{
$WScriptShell = New-Object -ComObject WScript.Shell
$Shortcut = $WScriptShell.CreateShortcut($ShortcutFile)
$Shortcut.TargetPath = $root_path
$Shortcut.Save()
}
This doesn't work as I'm sure any experienced powershell user knows. A file is created rather than a directory. I imagine the correct way to fix this is to change one of the object members in WScript.Shell which control's the file type. I have had no luck locating any resources on how to do this specifically, or any other way to go about doing it. I found the API on the MSDN website but there where only a few members listed. There must be more. What is the best way to accomplish this?
Thanks