Jump to content

Having issue with complicated syntax


Recommended Posts

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

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

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...

Link to comment
Share on other sites

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

  • Developers
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

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

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

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

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

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...