run compiled script issue Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Falko11
Posts: 3
Joined: 19 Oct 2023, 10:02

run compiled script issue

19 Oct 2023, 13:43

Hi,
I am using .bat script to disconnect from RDP session with

Code: Select all

tscon.exe 1 /dest:console
and i have setup shortcut to that cmd (Run as administrator is checked)

Code: Select all

C:\Windows\System32\cmd.exe /c "tscon.exe 1 /dest:console"
and everything is working fine.

Now I would like to do the same thing using AHK,
I have this code

Code: Select all

If Not A_IsAdmin 
{
  try
	 {
		Run, *RunAs %ComSpec% /c "cmd.exe /c "tscon.exe 1 /dest:console""
	 }
  Exitapp		
}		
Return
and this script is working fine when is executed from SciTE-based AutoHotkey script editor, it will disconnect my RDP session,
but when I compile this script and run that executable file, nothing is happened, my RDP session is still on.

Not sure where is the problem?

Just to mention if I run some other command (as administrator), for example:

Code: Select all

Run, *RunAs %ComSpec% /c "cmd.exe /c "chkdsk c:"
and create .exe file, I can run that executable file without problem.
Last edited by gregster on 19 Oct 2023, 15:51, edited 1 time in total.
Reason: Moved topic from AHK v2 help to v1 help, since this presumably a v1 question.
TAC109
Posts: 1129
Joined: 02 Oct 2013, 19:41
Location: New Zealand

Re: run compiled script issue

19 Oct 2023, 16:57

The Run command seems needlessly complicated. Try replacing it with:

Code: Select all

 Run, *RunAs %ComSpec% /c "tscon.exe 1 /dest:console"
Cheers
My scripts:-
XRef - Produces Cross Reference lists for scripts
ReClip - A Text Reformatting and Clip Management utility
ScriptGuard - Protects Compiled Scripts from Decompilation
I also maintain Ahk2Exe
Falko11
Posts: 3
Joined: 19 Oct 2023, 10:02

Re: run compiled script issue

23 Oct 2023, 05:31

TAC109, you are absolutely right it is a little bit complicated,
I tested your suggestion and still have same problem.
Just to explain how I am testing, I have install AHK (for testing purpose) on the pc which I am accessing through RDP.
I cannot just logoff, I have to disconnect RDP from that pc.
as i mention before,

Code: Select all

If Not A_IsAdmin 
{
  try
	 {
		Run, *RunAs %ComSpec% /c "cmd.exe /c "tscon.exe 1 /dest:console""
	 }
  Exitapp		
}		
Return
this script is working fine when is executed from SciTE-based AutoHotkey script editor, it will disconnect my RDP session exactly how I need.
But when I compile this script and run that executable file, nothing is happened, my RDP session is still on.

Still cannot figure out where is the problem?

Script is OK for sure, something is wrong with executing "script.exe" file or how is executing that file.
It does not matter if I am executing that "script.exe" as administrator, it still doing nothing.
Falko11
Posts: 3
Joined: 19 Oct 2023, 10:02

Re: run compiled script issue  Topic is solved

23 Oct 2023, 07:40

Hey Everyone, I read post "Problem with sciTE4autohotkey software", and then i realized that settings for current platform was Default, i swithched to x64 and compiled script and everything is working fine.
(did not pay attention that VM that i am executing script is 64 bit machine)

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Bing [Bot], Chunjee and 248 guests