rlake5 Posted July 3, 2019 Share Posted July 3, 2019 I have been trying different combinations all morning; I finally thought I would see if I can get some help! Here's the issue list: I have an EXE that needs to run in a command window It needs to run with admin privilege It has arguments / switches to pass through It will take a minute or so to complete I would like to see the cmd window as it runs to make sure the process completes successfully I would like to pass the drive letter to the command dynamically using a variable (it's running from a USB stick, so the drive letter may not always be the same) I had another script where I used $drive and a text box to have the user enter the drive letter assigned to the USB stick Thanks for any help; I will be happy to add / clarify as needed. Link to comment Share on other sites More sharing options...
Nine Posted July 3, 2019 Share Posted July 3, 2019 What do you have scripted so far ? Please post what you got using <> (before emoticon). “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
rlake5 Posted July 3, 2019 Author Share Posted July 3, 2019 Nine, I've tried several different avenues, none of which worked. I didn't want to post my garbage and have it clog up the thought process of someone who might have an idea for an answer. This is probably the thing that is closest, but still isn't quite right. $drive = InputBox("Question", "Enter the drive letter assigned to your USB drive WITH the colon", "", " M2") run (@ComSpec & " /c" & $drive & "\W10-NewCPU\defprof.exe <user> /q") Link to comment Share on other sites More sharing options...
Nine Posted July 3, 2019 Share Posted July 3, 2019 Please post what you got using <> (before emoticon). You are missing a space after /c. If you don't want to post more, I will not be able to help you out, as I will not write the code for you... “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
rlake5 Posted July 3, 2019 Author Share Posted July 3, 2019 I'm not asking you to write it; I have written dozens of other scripts on my own that work fine. I understand the process. I just can't get the odd pieces of this to work, specifically around running the EXE file in command mode - that's one I have not had to deal with before. I also tried this - RunAs("admin", "%computername%", "password", 2, "C:\Test\DefProf\defprof.exe pcmuser /q") - but it does not account for command mode. Interesting about the space, since the syntax checker did not flag that as an issue. Link to comment Share on other sites More sharing options...
Developers Jos Posted July 3, 2019 Developers Share Posted July 3, 2019 4 minutes ago, rlake5 said: Interesting about the space, since the syntax checker did not flag that as an issue. This is not an Autoit3 syntax issue but rather a commandline command issue: Run(@ComSpec & " /c" & $drive & "\W10-NewCPU\defprof.exe <user> /q") => C:\WINDOWS\system32\cmd.exe /cc:\W10-NewCPU\defprof.exe <user> /q so as indicated: An space is missing between /c en the rest. Use /k while testing so you can see any commandline issues as the comspec windows will remain open. Jos rlake5 1 SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
rlake5 Posted July 3, 2019 Author Share Posted July 3, 2019 Thanks Jos - I guess what I'm not understanding is how to call the command window as an admin, because it's the only way this defprof.exe app will run correctly. I'm using the runas and it starts the app, but the response is that I'm not running in admin mode. Link to comment Share on other sites More sharing options...
Nine Posted July 3, 2019 Share Posted July 3, 2019 use #requireadmin at beginning of script rlake5 1 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
rlake5 Posted July 3, 2019 Author Share Posted July 3, 2019 Nine - good suggestion. It's not quite as elegant as I was hoping for, but it is still very effective to get done what I am trying to do. I rewrote it like this and it works well. $drive = InputBox("Question", "Enter the drive letter assigned to your USB drive WITH the colon", "", " M2") #RequireAdmin RunWait(@comspec & " /c " & $drive & "W10-NewCPU\defprof.exe <user> /q") BTW - DefProf gets HUGE props from me as an easy way to set the default user profile in Win 10... if anyone cares / is interested. Link to comment Share on other sites More sharing options...
rlake5 Posted July 3, 2019 Author Share Posted July 3, 2019 Jos - it took me re-reading your response a couple of times before what you were saying sunk into my brain! Thanks for the explanation - that helped me correct and test to get a working result. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now