Jump to content
Sign in to follow this  
matt65

Script errors when CMD doesnt

Recommended Posts

matt65

Hi,

I am creating an autoit script which will silently install IIS7 onto a Windows 7 PC. I have found the required syntax of a CMD is:

start /w pkgmgr /l:log.etw /iu:IIS-WebServerRole;WAS-WindowsActivationService;WAS-ProcessModel;WAS-NetFxEnvironment;WAS-ConfigurationAPI

When I run this on the PC from the CMD prompt, IIS7 features are installed with no errors reported.

When I put this exact same syntax into a autoit script, I receive the error "An attempt was made to load a program with an incorrect format". The way in which I am calling the command is:

RunWait("cmd.exe /c ""start /w pkgmgr.exe /l:log.etw /iu:IIS-WebServerRole;WAS-WindowsActivationService;WAS-ProcessModel;WAS-NetFxEnvironment;WAS-ConfigurationAPI"" ","",@SW_SHOW)

I have also tried:

RunWait(@ComSpec & " /c ""start /w pkgmgr.exe /l:log.etw /iu:IIS-WebServerRole;WAS-WindowsActivationService;WAS-ProcessModel;WAS-NetFxEnvironment;WAS-ConfigurationAPI"" ","",@SW_SHOW)

Both of them result in the exact same error and no IIS features are installed.

Is anyone able to offer any suggestions on why running the command in a CMD prompt will succeed, but running the exact same command via autoit is resulting if failures?

I have attached the script I am using, it will only execute the command if your PC is Windows 7.

I appreaciate any assistance anyone is able to offer.

Matt

deploy-silent-IIS7.au3

Share this post


Link to post
Share on other sites
Fire

Hi and you are Welcome.

Check the Autoit help file for syntax of runwait()

It must be

RunWait("cmd.exe /c " & "start /w pkgmgr.exe /l:log.etw /iu:IIS-WebServerRole;WAS-WindowsActivationService;WAS-ProcessModel;WAS-NetFxEnvironment;WAS-ConfigurationAPI",@ScriptDir,@SW_SHOW)

And please when you copy/paste some autoit code use :

place here your code

Good Luck

Edited by Fire

[size="5"] [/size]

Share this post


Link to post
Share on other sites
Juvigy

Try :

RunWait(@COMSPEC & " /c start /w pkgmgr.exe /l:log.etw /iu:IIS-WebServerRole;WAS-WindowsActivationService;WAS-ProcessModel;WAS-NetFxEnvironment;WAS-ConfigurationAPI")

Share this post


Link to post
Share on other sites
matt65

Thank you both very much for your speedy replies.

Unfourtunately neither of these resolved the issue, the same error prompt is appearing.

Thanks Fire for the heads up on the correct syntax, means I have a lot of scripts to now update :mellow:

Is the RunWait function the correct choice for what I am after?

Share this post


Link to post
Share on other sites
Juvigy

What exactly is the error?

Maybe you need to specify full path to the pkgmgr.exe ?

Share this post


Link to post
Share on other sites
Fire

Hmm i change @Scriptdir to @Systemdir

Ok try this

RunWait("cmd.exe /c " & "start /w pkgmgr /l:log.etw /iu:IIS-WebServerRole;WAS-WindowsActivationService;WAS-ProcessModel;WAS-NetFxEnvironment;WAS-ConfigurationAPI",@SystemDir,@SW_SHOW)

:mellow:


[size="5"] [/size]

Share this post


Link to post
Share on other sites
UEZ

Try this:

$prg = "pkgmgr.exe"
$param1 = " /l:log.etw "
$param2 = " /iu:IIS-WebServerRole;WAS-WindowsActivationService;WAS-ProcessModel;WAS-NetFxEnvironment;WAS-ConfigurationAPI "

$run = @ComSpec & " /c " & $prg & $param1 & $param2

$start = RunWait($run, @WindowsDir, @SW_MAXIMIZE)

BR,

UEZ


Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites
matt65

Thanks to all for your assistance, unfourtunately none of the above worked in this instance.

I found another command to run using dism, which is the replacement for pkgmgr on Windows 7.

It is most likely related to my problems above, when calling DISM I kept getting an error that the 64-bit version needs to be used. It turns out that on a 64-bit PC certain internal commands get somewhat confused in that they run a 64-bit exe but are using the 32-bit dll.

My fix was to use the following:

RunWait("cmd.exe /k " & "C:\Windows\SysNative\dism.exe /online /enable-feature /featurename:""IIS-WebServerRole"" ", @WindowsDir, @SW_SHOW)

c:\windows\sysnative is a folder which you cant browse too, but it does exist and the above command succeeded.

I thank you all for your assistance with my problem, and while it wasnt an AutoIT issue I have learnt a little more about AutoIT throughout this excercise.

Matt

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
Sign in to follow this  

×