Created
March 3, 2017 14:03
-
-
Save paulwinex/86a1f7f4203f154ad5b48db123072c8b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Create shortcut on desktop for windows | |
#................................... | |
def createShortCut(self, data): | |
executable = join(os.getenv('PIPELINE_LOCATION'), 'start_app.cmd') | |
if not os.path.exists(executable): | |
self.trayMessage('Launcher not found') | |
return | |
data['launcher'] = executable.replace('/','\\') | |
data['wd'] = os.getenv('PIPELINE_LOCATION') | |
ico = icons[data['name']] if data['name'] in icons else icons['default'] | |
data['ico'] = os.path.splitext(ico)[0] + '.ico' | |
vb = r''' | |
Set objShell = WScript.CreateObject("WScript.Shell") | |
strDesktopFolder = objShell.SpecialFolders("Desktop") | |
Set objShortCut = objShell.CreateShortcut(strDesktopFolder & "\{title} {version}.lnk") | |
objShortCut.TargetPath = "{launcher}" | |
objShortCut.IconLocation = "{ico}" | |
objShortCut.WindowStyle = "7" | |
objShortCut.Description = "Pipeline launcher" | |
objShortCut.Arguments = chr(34) & "{name}" & chr(34) & " " & chr(34) & "{path}" & chr(34) | |
objShortCut.WorkingDirectory = "{wd}" | |
objShortCut.Save'''.format(**data) | |
fileTemp = tempfile.NamedTemporaryFile(delete = False, suffix='.vbs') | |
fileTemp.write(vb) | |
fileTemp.close() | |
#create shortcut on desktop | |
os.startfile(fileTemp.name) | |
#................................... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment