Dictionary Items Not Working When Passed Through Powershell Command
I have a dictionary created from a .txt file that contains desktop links. I need these links to be plugged in to a powershell command. However when I use '%s' % my_data[key] I get
Solution 1:
I found that the double backslash was not the problem. for my code subprocess.Popen([r"powershell.exe", r"$sh = New-Object -COM WScript.Shell" + "\n" + "$sh.CreateShortcut(%s).TargetPath" % my_data[key]], stdout=subprocess.PIPE).communicate()[0]
.
The dictionary had \n at the end of each line. I used my_dict[key].replace("\n","")
to get rid of it. also the path needed "path" \"%s\"
fixed that. I don't know how powershell was able to handle the double backslash???? but it did
Post a Comment for "Dictionary Items Not Working When Passed Through Powershell Command"