aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Ankarström <john@ankarstrom.se>2021-01-18 16:54:33 +0100
committerJohn Ankarström <john@ankarstrom.se>2021-01-18 16:54:33 +0100
commit08daf6e5443ac21daf9bf026cd2e29cba044fbeb (patch)
treec20db77dd582da115df88eba52d6f1b30a83a7a8
parent6586bf25abc295e6003bd6df284cd7d4b2015dbd (diff)
downloadahk-08daf6e5443ac21daf9bf026cd2e29cba044fbeb.tar.gz
programs.explorer: Open cmd as user with new RunAsUser function
I usually run the script as administrator, but this creates friction when logged into Windows as a non-administrator. For example, mounted SMB shares are not available in the administrator's cmd window.
-rw-r--r--tt.programs.explorer.ahk8
1 files changed, 7 insertions, 1 deletions
diff --git a/tt.programs.explorer.ahk b/tt.programs.explorer.ahk
index 3bebd6d..dead96c 100644
--- a/tt.programs.explorer.ahk
+++ b/tt.programs.explorer.ahk
@@ -32,6 +32,12 @@ ExplorerPath()
return Explorer().Document.Folder.Self.path
}
+RunAsUser(cmd*)
+{
+ global ShellApp
+ return ShellApp.Windows.FindWindowSW(0, 0, 8, 0, 1).Document.Application.ShellExecute(cmd*)
+}
+
;; -> body
;; Explorer/Desktop hotkeys ---------------------------------------------------
@@ -45,7 +51,7 @@ ExplorerPath()
; Open new window/command prompt
^n::Run, % "explorer /n,""" ExplorerPath() """"
-^p::Run, % "cmd /k cd /d """ ExplorerPath() """"
+^p::RunAsUser("cmd", "/k cd /d """ ExplorerPath() """")
+^p::
path := ExplorerPath()