Jump to content

Problem execute batch file with parameters


Recommended Posts

Hello,

Today I'm working with Office 2016 Deployment tool, all is working, but... at the end of office deploy i need to launch manually the file oemsetup.cmd with Mode=OEM parameter.

In an elevate Administrator i launch the command oemesetup.cmd Mode=OEM and all is working fine, but i would like to automate this command in Autoit.

I test this commands and no one seems to work:

#include <Process.au3>

$dos_command = '"' & @ScriptDir & '\oemsetup.cmd" Mode=OEM'

$retval = RunWait(@ComSpec & " /c " & $dos_command,@ScriptDir)
Msgbox(0,"RunWait",$retval)
$retval = _RunDos(@ComSpec & " /c " & $dos_command)
Msgbox(0,"_RunDos",$retval)

all the command return 255.

OS: Win10.586 x64

can someone help me to fix this problem ?? Thank you.

 

:rolleyes:

Link to comment
Share on other sites

  • Developers

Have you tried setting the workdir parameter to the @scriptdir as well on the runwait command

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

  • Developers

Why are you adding the scriptdir at all since you stated you done do that from the command prompt?

Are you running the script in Admin mode and how did you do that?

Jos

Edited by 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

#RequireAdmin
#include <Process.au3>

$dos_command = '"' & @ScriptDir & '\oemsetup.cmd" Mode=OEM'

$retval = RunWait(@ComSpec & " /c " & $dos_command)
Msgbox(0,"RunWait",$retval)
$retval = _RunDos(@ComSpec & " /c " & $dos_command)
Msgbox(0,"_RunDos",$retval)

 

add requireadmin and remove @Scriptdir ... not working

:rolleyes:

Link to comment
Share on other sites

#RequireAdmin
#include <Process.au3>

$dos_command = 'oemsetup.cmd Mode=OEM'

$retval = RunWait(@ComSpec & " /c " & $dos_command)
Msgbox(0,"RunWait",$retval)
$retval = _RunDos(@ComSpec & " /c " & $dos_command)
Msgbox(0,"_RunDos",$retval)

 

remove @scriptdir from command... not working (compiled script exe is in the same directory of oemsetup.cmd)

:rolleyes:

Link to comment
Share on other sites

  • Developers

So back to the basics:

  • What is the exact command you type in the admin level CMD window ?
  • Which directory is the workdir at that moment?
  • What is the issue when you run the script?
  • Try running it with /k in stead of /c to see if there is any error shown.

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

  • Developers

Don't need that as you can look into that yourself and find the reference to this error...right? ;)
The thing is that I asked 4 questions and am missing the answer of the first 3! :)
You need to determine what is different in running it manually from the CMD prompt and via the script!

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

I test this in a VM with Windows 10.586 in Audit Mode (CTRL-SHIFT-F3). This VM have 2 virtual drive C: and D:

In C: this is only OS. In D: there is a folder

D:\O2K16OEM ... in this folders there are two files myscript.exe (compiled script for automate oemsetup.cmd and silent install office) and oemsetup.cmd

If i run Comand Prompt like administrator and go to D:\O2K16OEM and launch oemsetup.exe Mode=OEM

the command is working fine.

But If I launch myscript.exe whit (/k) i have in a dos box:

\Common not expected.

D:\O2K16OEM>

and the command is not working.

 

 

:rolleyes:

Link to comment
Share on other sites

  • Developers

Could it be an x86/x64 issue? HAve you tried running the command from a x86 cmd prompt?
Could also try compiling the script as an X64 outputfile.

Jos

Edited by 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

Quote

x86: not working ....\Common not expected ... error

That x86 @scriptdir wouldnt happen to be "\Common Files\" would it?  If so, try '"' & @scriptdir & '"'.

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

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