Jump to content
nss

how to launch programs the run dialog style?

Recommended Posts

nss

Hi all. I am creating an app that runs a program with the admin privileges using the shellexecute's run as verb, but what my problem is, that no matter what I use to launch the program, it doesn't quite work like the run dialog would (certain programs don't get found, etc.). I've tried using the explorer.exe and passing the program to it, that is unreliable and opens documents folder sometimes instead, I've tried using the @comspec /c and that works better, but still some of the programs aren't being found that would be with the run dialog e.g., if I do @comspec /c diskpart it won't find it, I've even tried setting the working dir, but still no luck. I also tried passing commandline params to C:\WINDOWS\system32\rundll32.exe shell32.dll,#61, but no luck. can anyone help me what way to go in order to be able to launch programs in the run dialog style? is there a function in winapi that run dialog uses that I could use as well? Or what would be the best way to go about this? Any help much appreciated.

Share this post


Link to post
Share on other sites
careca

This used to work for me, but now i guess that windows 10 has something to do with it..

#include <Constants.au3>
Local $dif
ListLetter()
Func ListLetter()
    ProgressOn('Diskpart', 'Working', '', 300, 300)
    ProgressSet(25, '', 'Working...')
    $DSK = Run('diskpart', '', @SW_HIDE, $STDIN_CHILD + $STDOUT_CHILD)
    ;$DSK = ShellExecute('diskpart', $STDIN_CHILD + $STDOUT_CHILD, '', '', @SW_HIDE)
    ConsoleWrite('$DSK - ' & @error & ' - ' & @MSEC & @CRLF)
    $begin = TimerInit()
    Do
        If $dif >= 3000 Then
            MsgBox(64, 'Params', 'Timeout')
            ExitLoop
        EndIf
        $dif = TimerDiff($begin)
        ProgressSet(35, '', 'Working...')
        $Read = StdoutRead($DSK, True, False)
        $Str = StringInStr($Read, 'DISKPART>')
    Until $Str <> 0
    ProgressSet(65, '', 'Working...')
    StdinWrite($DSK, "list volume" & @CRLF)
    $begin = TimerInit()
    Do
        If $dif >= 3000 Then
            MsgBox(64, 'Params', 'Timeout')
            ExitLoop
        EndIf
        $dif = TimerDiff($begin)
        $Read = StdoutRead($DSK, True, False)
        $Str1 = StringInStr($Read, 'DISKPART>', 0, 2)
    Until $Str1 <> 0
    ProgressSet(85, '', 'Working...')
    $Read = StdoutRead($DSK, True, False)
    ProgressOff()
    MsgBox(4096, "Diskpart - List Volume", $Read)
EndFunc   ;==>ListLetter

Looks like diskpart is different from regular console.

Edited by careca

Spoiler

Paster - Main function is to paste text, but has more functions. (No longer mantained, switched to String Trigger)

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Firefox Profile Backup - Backup/restore previously saved profile.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

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

  • Similar Content

    • AnonymousX
      By AnonymousX
      So I just got a new computer, and instantly went and installed Autoit onto it. I selected run script as default action when clicking on an au3 file, however every time I do this it opens the script in the editor. I can from there run the script no problem.
      I've tried reinstalling and checking the settings by hitting "Ctrl+1" and have confirmed it is set to run, but yet it just continues to open in the editor.
      Any ideas why this is happening or how to solve?
      New system is windows 10, old was windows 7
    • HariKara
      By HariKara
      Hi AutoIters!
       
      Im trying to launch a .exe file that is nested within the program files (x86) folder structure. i have already used the standard RunAs Syntax and found that it fails to launch the application. I have switched to Run and that seems to work. My issue is I have to use RunAs as the applicaton would need to run under a completely different account. The Current logged in user is a Local User on the machine, however, the application must be run as a domain user. The Machine is domain connected.
       
       have tried the following:
      RunAs("username","logonpassword", $RUN_LOGON_PROFILE, "D:\Program Files (x86)\Vendor\Application Name\Exe Location\Executable.exe") The above fails to launch, there are no errors or syntax issues, it just does nothing when the variables are replaced for the correct values.
      I did the same using the Run command
      Run("D:\Program Files (x86)\Vendor\Application Name\Exe Location\Executable.exe") That seems to work fine, but runs in local user context. Any thoughts? Could it be a local Machine rights issue? Or have i missed something glaring in my script
    • nacerbaaziz
      By nacerbaaziz
      Hello
      i have searched a lot about how to run external programs with the administrator privileges without the script running with administrator privileges using autoit
      But all my attempts failed
      Finally, today I found the VBS function doing this task
      I immediately transferred it to our beloved language (autoit) and i decided to share it with you
      i hope you like it
      This is a simple example about how to use the function

      runAsAdmin("cmd.exe", "/c @echo off & cls & echo test & pause", "c:\", @sw_show)
      this is the function

      func runAsAdmin($program, $parameters = "", $workingDir = @workingDir, $show = "") local $oShell = OBJCreate("Shell.Application") if isOBJ($oShell) then local $result = $oShell.ShellExecute($program, $parameters, $workingDir, "runas", $show) else $result = false endIf return $result endFunc
       
    • PoojaKrishna
      By PoojaKrishna
      Hi friends,
      The Run command on my machine suddenly stopped execution.
      Anyone of you facing the same issue?
      #include <AutoItConstants.au3> #include <FileConstants.au3.> #RequireAdmin $ExeName = FileOpenDialog("Select AutoIt executable", @ScriptDir & "\", "(*.exe)", $FD_FILEMUSTEXIST) If not @error Then If FileExists($ExeName) Then $iPID = Run($ExeName, "", @SW_HIDE, $STDIN_CHILD + $STDOUT_CHILD) If @error Then msgbox(0,"Failed", "Failed execution with @error: " & @error) EndIf Else Msgbox(0,"", "File does not exist") EndIf EndIf The above code always fails to execute the executable file. It was working perfect and stopped working now.
      I have tried adding the files and folders to windows defender exclusion list and uninstalling the anti virus but still no luck.
      OS: Windows 10 - 64 bit
      Please help.
       
    • nacerbaaziz
      By nacerbaaziz
      Hello, dears.
      First I apologise to you for the stupid question I'm going to ask.
      is the default style for Windows created using AutoIt   a dialog box style?
      I decided to ask this question
      Because I am using a screen reader
      If i open any program that is designed using autoit, the screen reader read for example,  
      test dialog
      but If i open any other program, for example goldwave, it read goldwav only without a word dialog
      Is there a solution to this
      The code i used to create the window is:
      $hGUI = GUICreate(str("title"), 500, 420, -1, -1, BitOr($WS_MAXIMIZEBOX, $WS_MINIMIZEBOX, $WS_SIZEBOX, $WS_SYSMENU, $WS_CAPTION), BitOr($WS_EX_ACCEPTFILES,$WS_EX_LAYERED,$WS_EX_CLIENTEDGE,$WS_EX_STATICEDGE))
      I hope to find a solution to this problem
      please Accept my greetings, and thank you very much.
×