Sign in to follow this  
Followers 0
DevSpark

Problem Running Script Interactivley

9 posts in this topic

My machine is 64 bit and I am running my AutoIt script through a job scheduler interactively. If I do something like: Run("Explorer.exe") it works fine and Explorer opens on my screen. However if I try to open Notepad or Cmd.exe I get a popup saying "A program on this computer is trying to display a message." and if I view the message I get a blank screen with Notepad or cmd opened. What causes this and why does explorer not have any issues opening?

Share this post


Link to post
Share on other sites



This happens when a program is being run from a different user account but it is displaying the window in your user session. I would imagine that it is running from the System Account since you are using the Task Scheduler. Change the logon credentials for the Task and you should not see this message.

Share this post


Link to post
Share on other sites

This happens when a program is being run from a different user account but it is displaying the window in your user session. I would imagine that it is running from the System Account since you are using the Task Scheduler. Change the logon credentials for the Task and you should not see this message.

I double checked and the job is running under my credentials and as I understand it should be displaying on my desktop. I am confused why explorer runs on my desktop but cmd.exe does not.

Share this post


Link to post
Share on other sites

What do you get with this?

__Run("notepad.exe")

Func __Run($s_program, $s_workdir = "", $i_show = @SW_SHOW, $i_opt_flag = 0)

    If @OSArch = "X86" Then
        Return Run($s_program, $s_workdir, $i_show, $i_opt_flag)
    EndIf

    Local $t_int = DllStructCreate("int")
    Local $p_int = DllStructGetPtr($t_int)

    DllCall("kernel32.dll", "int", "Wow64DisableWow64FsRedirection", "ptr", $p_int)
    Local $i_pid = Run($s_program, $s_workdir, $i_show, $i_opt_flag)
    DllCall("kernel32.dll", "int", "Wow64RevertWow64FsRedirection", "ptr", $p_int)

    Return $i_pid
EndFunc

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

What do you get with this?

__Run("notepad.exe")

Func __Run($s_program, $s_workdir = "", $i_show = @SW_SHOW, $i_opt_flag = 0)

    If @OSArch = "X86" Then
        Return Run($s_program, $s_workdir, $i_show, $i_opt_flag)
    EndIf

    Local $t_int = DllStructCreate("int")
    Local $p_int = DllStructGetPtr($t_int)

    DllCall("kernel32.dll", "int", "Wow64DisableWow64FsRedirection", "ptr", $p_int)
    Local $i_pid = Run($s_program, $s_workdir, $i_show, $i_opt_flag)
    DllCall("kernel32.dll", "int", "Wow64RevertWow64FsRedirection", "ptr", $p_int)

    Return $i_pid
EndFunc

It has the same exact result. I get the pop notification about a program trying to display a message. Could this be an ACL or permission issue?

Share this post


Link to post
Share on other sites

It could be, did you run as administrator?


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

The task is probably running in Session 0, which means you can't interact with it directly unless you use the /interactive parameter. I'm not sure how it would be done in AutoIt, but it wouldn't show for me using Scheduled Tasks unless I added that.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

The task is probably running in Session 0, which means you can't interact with it directly unless you use the /interactive parameter. I'm not sure how it would be done in AutoIt, but it wouldn't show for me using Scheduled Tasks unless I added that.

Yes, I am running the script as Administrator. Where does the /Interactive parameter need to be added?

Share this post


Link to post
Share on other sites

Try adding it after the command you want to run when you're setting up the scheduled task. I've never set up a scheduled task in AutoIt so I don't know the command you're using to do it, but you might try something along the lines of "@SystemDir " & " \cmd.exe /interactive" or just "cmd.exe /interactive" and see if that makes any difference.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0