Efo74

Problem execute batch file with parameters

18 posts in this topic

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:

Share this post


Link to post
Share on other sites



Yes, I have tied. :(


:rolleyes:

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

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

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
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:

Share this post


Link to post
Share on other sites

I'm not starting from command prompt. From command prompt I'm execute the batch directly


:rolleyes:

Share this post


Link to post
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:

Share this post


Link to post
Share on other sites

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

 

1 person likes this

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Thank you Jos : I don't know the command /k

whith /k I have this dos prompt:

\Common not expected.

D:\O2K16OEM>


:rolleyes:

Share this post


Link to post
Share on other sites

#11 ·  Posted

No ... but is a start.  Can I send you the batch file ?


:rolleyes:

Share this post


Link to post
Share on other sites

#12 ·  Posted

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


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#13 ·  Posted

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:

Share this post


Link to post
Share on other sites

#14 ·  Posted

oops the command is : oemsetup.cmd Mode=OEM


:rolleyes:

Share this post


Link to post
Share on other sites

#15 ·  Posted (edited)

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

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#16 ·  Posted

Thank you very much Jos.

This is a x86/64 issue: I have compile same script in x86/64

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

x64: working :lmao:

1 person likes this

:rolleyes:

Share this post


Link to post
Share on other sites

#18 ·  Posted

Quote

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

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


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

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