When I start Microsoft Outlook manually by clicking on its shortcut, the program automatically signs me in into my Gmail account at startup. But when I start Microsoft Outlook through AutoHotkey’s Run command, Outlook requires me to sign in manually. This may have to do with AutoHotkey’s permissions.
Does anyone know how to start Outlook through AutoHotkey with the highest permissions in order that Outlook may sign me in automatically into the Gmail account at startup?
AutoHotkey Permissions
-
- Posts: 348
- Joined: 27 Apr 2019, 17:38
Re: AutoHotkey Permissions
Just a guess what the actual difference might be: A shortcut usually has information about a working directory for the program it runs.
You can try to add that same working directory as the second parameter of Run. For some programs, it really makes a difference.
You can try to add that same working directory as the second parameter of Run. For some programs, it really makes a difference.
-
- Posts: 348
- Joined: 27 Apr 2019, 17:38
Re: AutoHotkey Permissions
The following is the command which I use to start Outlook:
Code: Select all
run % """C:\Program Files\Microsoft Office\root\Office16\OUTLOOK.EXE"""
Re: AutoHotkey Permissions
The suggestion is to add its directory as the second parameter, which is the WorkingDir parameter:
By the way, I'm usually a big proponent of using expression syntax over legacy syntax, but I don't see the advantage of forcing an expression for the first parameter in this case, so I showed it using legacy syntax (as I did for the second parameter).
Code: Select all
Run, "C:\Program Files\Microsoft Office\root\Office16\OUTLOOK.EXE", C:\Program Files\Microsoft Office\root\Office16
By the way, I'm usually a big proponent of using expression syntax over legacy syntax, but I don't see the advantage of forcing an expression for the first parameter in this case, so I showed it using legacy syntax (as I did for the second parameter).
-
- Posts: 348
- Joined: 27 Apr 2019, 17:38
Re: AutoHotkey Permissions
Thank you. I have tried using the above command, but Outlook still does not sign in automatically when it is launched through AutoHotkey automatically at system startup through the Task Scheduler. (The option “At logon” is selected in the Task Scheduler.)boiler wrote: ↑25 Mar 2022, 14:52The suggestion is to add its directory as the second parameter, which is the WorkingDir parameter:By the way, I'm usually a big proponent of using expression syntax over legacy syntax, but I don't see the advantage of forcing an expression for the first parameter in this case, so I showed it using legacy syntax (as I did for the second parameter).Code: Select all
Run, "C:\Program Files\Microsoft Office\root\Office16\OUTLOOK.EXE", C:\Program Files\Microsoft Office\root\Office16
Re: AutoHotkey Permissions
You might want to show all the properties in the shortcut you use manually because it may be passing some arguments to Outlook as it runs it that you could add to your Run command.
-
- Posts: 348
- Joined: 27 Apr 2019, 17:38
Re: AutoHotkey Permissions
I think you need to specify the profile in your command line arg:
Code: Select all
C:\Program Files\Microsoft Office\root\Office16\OUTLOOK.EXE /profile "NAMEOFPROFILE"
So much universe, and so little time. GNU Sir Terry.
-
- Posts: 348
- Joined: 27 Apr 2019, 17:38
Re: AutoHotkey Permissions
Do you mean the Windows user name or the computer name (both of which are chosen during Windows 11 installation)?MrDodel wrote: ↑27 Mar 2022, 14:47I think you need to specify the profile in your command line arg:Code: Select all
C:\Program Files\Microsoft Office\root\Office16\OUTLOOK.EXE /profile "NAMEOFPROFILE"
Should this name be specified in the Outlook.exe file shortcut or in the AutoHotkey Run command?
Re: AutoHotkey Permissions
It's the email profile name, so if you go to control panel, select mail, then the profile tab you can see the name of the profile you have setup in outlook, you then pass that profile name to outlook.exe as shown above.Alexander2 wrote: ↑28 Mar 2022, 12:40Do you mean the Windows user name or the computer name (both of which are chosen during Windows 11 installation)?MrDodel wrote: ↑27 Mar 2022, 14:47I think you need to specify the profile in your command line arg:Code: Select all
C:\Program Files\Microsoft Office\root\Office16\OUTLOOK.EXE /profile "NAMEOFPROFILE"
Should this name be specified in the Outlook.exe file shortcut or in the AutoHotkey Run command?
- Attachments
-
- image.png (17.2 KiB) Viewed 2233 times
So much universe, and so little time. GNU Sir Terry.
-
- Posts: 348
- Joined: 27 Apr 2019, 17:38
Re: AutoHotkey Permissions
Thank you for the explanation.
The Control Panel shows that that the name of the profile is “Outlook”:
I have added the parameter in Outlook’s shortcut: However, Outlook still does not sign in automatically when its shortcut is opened by AutoHotkey at system log on.
The Control Panel shows that that the name of the profile is “Outlook”:
I have added the parameter in Outlook’s shortcut: However, Outlook still does not sign in automatically when its shortcut is opened by AutoHotkey at system log on.
Re: AutoHotkey Permissions
You didn’t say you were running the shortcut from your AHK script, at least not that I saw. Is that what you are trying now? Can you show that script?
-
- Posts: 348
- Joined: 27 Apr 2019, 17:38
Re: AutoHotkey Permissions
Yes, I have tried launching Outlook also through its shortcut with the use of AutoHotkey.
I have tried running both of the following commands, but in each instance Outlook does not sign in automatically when it is launched through Autohotkey at system log on:
Code: Select all
run "C:\Program Files\Microsoft Office\root\Office16\OUTLOOK.EXE" /profile Outlook
Code: Select all
run % """C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Outlook.lnk"""
Re: AutoHotkey Permissions
Have you tried shellrun, I'm having the same problem tring to run explorer as the loged in user, when running the script as a admin. Yet shellrun may work for you?
-
- Posts: 348
- Joined: 27 Apr 2019, 17:38
Re: AutoHotkey Permissions
I can try using this command. How can this command be run in an AutoHotkey script to launch Outlook with the specified profile name?
Re: AutoHotkey Permissions
Try here, were I see info. viewtopic.php?t=92700
Also my topic almost about the same problem here
viewtopic.php?t=102099
Also how do you start via task scheduler, what user, are you run with highest privileges, as could be due to this. To start outlook it would need ahk to be running as that user with standard privileges. Also you can add a delay to the task start like 5seconds or more.
Running as a admin then as x users profile may be the problem
Sorry for the edit, it's late.
Also my topic almost about the same problem here
viewtopic.php?t=102099
Also how do you start via task scheduler, what user, are you run with highest privileges, as could be due to this. To start outlook it would need ahk to be running as that user with standard privileges. Also you can add a delay to the task start like 5seconds or more.
Running as a admin then as x users profile may be the problem
Sorry for the edit, it's late.
-
- Posts: 348
- Joined: 27 Apr 2019, 17:38
Re: AutoHotkey Permissions
Thank you for the information. Since I do not have much programming knowledge, I do not understand what is stated in those threads. Perhaps there may be a simpler way to run Outlook normally.Try here, were I see info. viewtopic.php?t=92700
Also my topic almost about the same problem here
viewtopic.php?t=102099
The following are the parameters in the Task Scheduler: The option “Run with the highest privileges” is checked because the AutoHotkey script runs at system log only when this option is selected.Also how do you start via task scheduler, what user, are you run with highest privileges, as could be due to this. To start outlook it would need ahk to be running as that user with standard privileges.
The delay is already added in the AutoHotkey script. The script launches Outlook more than a minute after the script is run. But Outloook still does not sign in automatically.Also you can add a delay to the task start like 5seconds or more.
Re: AutoHotkey Permissions
seems you might try the RunAs command for your script to apply the correct user context. the scheduled task causes an administrative context to the script which needs to be specific to the current user
We are troubled on every side‚ yet not distressed; we are perplexed‚
but not in despair; Persecuted‚ but not forsaken; cast down‚ but not destroyed;
Telegram is the best way to reach me
https://t.me/ttnnkkrr
If you have forum suggestions please submit a
Check Out WebWriter
but not in despair; Persecuted‚ but not forsaken; cast down‚ but not destroyed;
Telegram is the best way to reach me
https://t.me/ttnnkkrr
If you have forum suggestions please submit a
Check Out WebWriter
Re: AutoHotkey Permissions
In picture 2 edit trigger, delay task for put 30 seconds. See if that works else can try this
The first part of the code is to get your command to run as a user. Just not sure if it will work. The bottom command can then be put in your script to replace the run.
Code: Select all
/*
ShellRun by Lexikos
requires: AutoHotkey v1.1
license: http://creativecommons.org/publicdomain/zero/1.0/
Credit for explaining this method goes to BrandonLive:
http://brandonlive.com/2008/04/27/getting-the-shell-to-run-an-application-for-you-part-2-how/
Shell.ShellExecute(File [, Arguments, Directory, Operation, Show])
http://msdn.microsoft.com/en-us/library/windows/desktop/gg537745
*/
ShellRun(prms*)
{
shellWindows := ComObjCreate("Shell.Application").Windows
VarSetCapacity(_hwnd, 4, 0)
desktop := shellWindows.FindWindowSW(0, "", 8, ComObj(0x4003, &_hwnd), 1)
; Retrieve top-level browser object.
if ptlb := ComObjQuery(desktop
, "{4C96BE40-915C-11CF-99D3-00AA004AE837}" ; SID_STopLevelBrowser
, "{000214E2-0000-0000-C000-000000000046}") ; IID_IShellBrowser
{
; IShellBrowser.QueryActiveShellView -> IShellView
if DllCall(NumGet(NumGet(ptlb+0)+15*A_PtrSize), "ptr", ptlb, "ptr*", psv:=0) = 0
{
; Define IID_IDispatch.
VarSetCapacity(IID_IDispatch, 16)
NumPut(0x46000000000000C0, NumPut(0x20400, IID_IDispatch, "int64"), "int64")
; IShellView.GetItemObject -> IDispatch (object which implements IShellFolderViewDual)
DllCall(NumGet(NumGet(psv+0)+15*A_PtrSize), "ptr", psv
, "uint", 0, "ptr", &IID_IDispatch, "ptr*", pdisp:=0)
; Get Shell object.
shell := ComObj(9,pdisp,1).Application
; IShellDispatch2.ShellExecute
shell.ShellExecute(prms*)
ObjRelease(psv)
}
ObjRelease(ptlb)
}
}
; ------------ here you put your run line ----------
ShellRun("outlook.exe /profile")
Re: AutoHotkey Permissions
Or shellrun("outlook.exe")