Skip to content

Commit

Permalink
Windows start menu stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
Seva Alekseyev committed Feb 6, 2020
1 parent 297b338 commit 6e89bfd
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 20 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/test/testlocal.py
/samples
__pycache__
.vscode
.vscode
/dwex.egg-info
/dist
41 changes: 22 additions & 19 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,28 @@
import platform, sys, os
from os import path, environ

#------------------------------------
# Start menu item creation on Windows
#------------------------------------

def create_shortcut_under(root, exepath, nulfile):
import subprocess
profile = environ[root]
s = "$s=(New-Object -COM WScript.Shell).CreateShortcut('" + profile + "\\Microsoft\\Windows\\Start Menu\\Programs\\DWARF Explorer.lnk');"
s += "$s.TargetPath='" + exepath + "';$s.Save()"
return subprocess.call(['powershell', s], stdout = nulfile, stderr = nulfile) == 0

def create_shortcut():
try:
exepath = path.join(path.dirname(sys.executable), "Scripts", "dwex.exe")
with open(os.devnull, 'w') as nulfile:
if not create_shortcut_under('ALLUSERSPROFILE', exepath, nulfile):
create_shortcut_under('APPDATA', exepath, nulfile)
except:
pass

#--------------------------------------

class my_install(install):
def run(self):
install.run(self)
Expand Down Expand Up @@ -53,22 +75,3 @@ def run(self):
]
)

#------------------------------------
# Start menu item creation on Windows
#------------------------------------

def create_shortcut_under(root, exepath, nulfile):
import subprocess
profile = environ[root]
s = "$s=(New-Object -COM WScript.Shell).CreateShortcut('" + profile + "\\Microsoft\\Windows\\Start Menu\\Programs\\DWARF Explorer.lnk');"
s += "$s.TargetPath='" + exepath + "';$s.Save()"
return subprocess.call(['powershell', s], stdout = nulfile, stderr = nulfile) == 0

def create_shortcut():
try:
exepath = path.join(path.dirname(sys.executable), "Scripts", "dwex.exe")
with open(os.devnull, 'w') as nulfile:
if not create_shortcut_under('ALLUSERSPROFILE', exepath, nulfile):
create_shortcut_under('APPDATA', exepath, nulfile)
except:
pass

0 comments on commit 6e89bfd

Please sign in to comment.