Jump to content

Trouble with command line parameter in RunWait()


Go to solution Solved by jguinch,

Recommended Posts

So I am making a script to automatically isntall some software for a company i work with.  Most of the software i had no trouble just using run, but this 1 line is giving me trouble.  It just opens cmd and closes instantly without doing anything.

I have been trying to get it to work with @comspec.

The line of code is

RunWait(@comspec & ' /c "\\pafile\WindebtXL\WindebtXLPA\WinDebt SQL\Setup\setup.exe" /s /v"/qn /L*v \"%temp%\wdins.log\" USERNAME="Lmm" AGREETOLICENSE=Yes COMPANYNAME=\"Lmm Management\""')

I know that the actual command works because i can go into command prompt, or run, and type it exactly like this:

"pafileWindebtXLWindebtXLPAWinDebt SQLSetupsetup.exe" /s /v"/qn /L*v "%temp%wdins.log" USERNAME="Lmm" AGREETOLICENSE=Yes COMPANYNAME="Lmm Management""

 

I changed the RunWait to Send, and had it type into the run window.

It appears to output exactly what i want:

C:Windowssystem32cmd.exe /c "pafileWindebtXLWindebtXLPAWinDebt SQLSetupsetup.exe" /s /v"/qn /L*v "%temp%wdins.log" USERNAME="Lmm" AGREETOLICENSE=Yes COMPANYNAME="Lmm Management""

The only part I am not sure about is the part that @comspec & '/c' is doing.  Does that look like how it is supposed to be?

Another thing i noticed is that it seems like it is the space in the file path that screws it up, even though the send output had the file path inside quotes.  If i rename the folder in my testing area then i do not have any issues running the command exactly like it is.  Issue is i cannot rename the original folder because other things point to it.  Any ideas where i went wrong?  The line is pretty complex and I am hoping there is jsut a misplaced quote or something.  Thanks.

Forgot to mention that i can use:

send("#r")
Send('"\\pafile\WindebtXL\WindebtXLPA\WinDebt SQL\Setup\setup.exe" /s /v"/qn /L*v \"%temp%\wdins.log\" USERNAME="Lmm" AGREETOLICENSE=Yes COMPANYNAME=\"Lmm Management\"{Enter}')

Doing this works without any problems, so i keep coming back to me using @comspec wrong.

Edited by tykkimies
Link to comment
Share on other sites

Hello,

If you have run that command line and it worked if there is no space in any dir, then try to convert the folder with space from long to short name, something like this:

RunWait(@comspec & ' /c "\\pafile\WindebtXL\WindebtXLPA\WinDeb~1\Setup\setup.exe" /s /v"/qn /L*v \"%temp%\wdins.log\" USERNAME="Lmm" AGREETOLICENSE=Yes COMPANYNAME=\"Lmm Management\""')

By the way, when you test this kind of command, it's better to use parameter /k instead of /c, parameter /k will keep active the command window so you could see whether there is any error to debug the problem. Exceute cmd.exe /? to see what are the parms available.

Cheers,

sahsanu

Link to comment
Share on other sites

When i put in the /k i shows file path cannot be found.

I got the shortname for that path using FileGetShortName and tried this:

RunWait(@comspec & ' /k "\\pafile\WindebtXL\WINDEB~1\WinDeb~1\Setup\setup.exe" /s /v"/qn /L*v \"%temp%\wdins.log\" USERNAME="Lmm" AGREETOLICENSE=Yes COMPANYNAME=\"Lmm Management\""')

Still cannot find file path.  It just seems weird that i can have the send command type in exactly what is after @comspec & '/c/ and then hit enter and my program installs fine.  I don't really understand why @comspec isn't working in this command.

Link to comment
Share on other sites

You can try to add the workingdir parameter in your RunWait call (set it to a local path).

Also, you could see more infos with a echo command.

RunWait(@comspec & ' /k echo "\\pafile\WindebtXL\WINDEB~1\WinDeb~1\Setup\setup.exe" /s /v"/qn /L*v \"%temp%\wdins.log\" USERNAME="Lmm" AGREETOLICENSE=Yes COMPANYNAME=\"Lmm Management\""')
Link to comment
Share on other sites

Just tried using Echo like jguinch suggested.  Was a great idea. 

RunWait(@comspec & ' /k echo "\\pafile\WindebtXL\WINDEB~1\WinDeb~1\Setup\setup.exe" /s /v"/qn USERNAME="Lmm" AGREETOLICENSE=Yes COMPANYNAME=\"Lmm Management\""')

I took what was output to the command prompt.

went to a new line which started C:Users... like normal

From there i entered in exactly what was sent back by the command prompt and it installed correctly.  What is making it not work when i use the RunWait command?

to Sahsanu.  #RequireAdmin is already set, and the install is going on a 32 bit machine.

Link to comment
Share on other sites

Regarding 64 bit OS, if you are launching now the command from a 64 bits OS to test it, believe me, it could made the difference ;).

Try to run the command without @comspec, the command directly:

RunWait('\\pafile\WindebtXL\WINDEB~1\WinDeb~1\Setup\setup.exe /s /v"/qn /L*v \"%temp%\wdins.log\" USERNAME="Lmm" AGREETOLICENSE=Yes COMPANYNAME=\"Lmm Management\""')

Keep in mind that %temp% could not be expanded so you have two options, remove %temp% and put the full path for temp dir or add this option in your script:

Opt("ExpandEnvStrings",1)
RunWait('\\pafile\WindebtXL\WINDEB~1\WinDeb~1\Setup\setup.exe /s /v"/qn /L*v \"%temp%\wdins.log\" USERNAME="Lmm" AGREETOLICENSE=Yes COMPANYNAME=\"Lmm Management\""')

By the way, do you need to quote this?:

"/qn /L*v \"%temp%\wdins.log\" USERNAME="Lmm" AGREETOLICENSE=Yes COMPANYNAME=\"Lmm Management\""

And why are you escaping several ?.

You could also try several variants of the command:

RunWait('\\pafile\WindebtXL\WINDEB~1\WinDeb~1\Setup\setup.exe /s /v"/qn /L*v \"%temp%\wdins.log\" USERNAME="Lmm" AGREETOLICENSE=Yes COMPANYNAME=\"Lmm Management\""', @ScriptDir)

RunWait('\\pafile\WindebtXL\WINDEB~1\WinDeb~1\Setup\setup.exe /s /v /qn /L*v "%temp%\wdins.log" USERNAME="Lmm" AGREETOLICENSE=Yes COMPANYNAME="Lmm Management"')

RunWait('\\pafile\WindebtXL\WINDEB~1\WinDeb~1\Setup\setup.exe /s /v /qn /L*v "%temp%\wdins.log" USERNAME="Lmm" AGREETOLICENSE=Yes COMPANYNAME="Lmm Management"', @ScriptDir)

If none works... I'm running out of ideas :(

Cheers,

sahsanu

Link to comment
Share on other sites

/v"/qn /L*v \"%temp%\wdins.log\" USERNAME="Lmm" AGREETOLICENSE=Yes COMPANYNAME=\"Lmm Management\""

Quoting this is about the only thing i am sure about at this point lol.  /v is what lets me pass parameters to msiexec, and the parameters need to come before the end of /v so it needs to be in quotes.  I spet hours researching this last night jsut to get this command working before i even started scripting it.  The reason i am escaping is so the log path gets its own set of quotes, and so that the Company Name can contain a space.  That was the worst part of everything.  I could only get it to work using COMPANYNAME="LmmManagement" for so long until i escaped those parens.

I am working on copying the folder locally to a 64bit machine now to test out some of your suggestions.  I do know that just using RunWait() doesn't work because thats where i was at before i even attempted @comspec.  I will let you know how it goes.  And i am gonna flat out remove the log file at this point, because i know the parameters are getting passed correctly.  Should make it a little easier to read.

Link to comment
Share on other sites

OK here is what i have found.

Copied it locally and tried - windows 8 64bit

Run('"C:\Users\Pat\Desktop\Setup\setup.exe" /s /v"/qn USERNAME="Lmm" AGREETOLICENSE=Yes COMPANYNAME=\"Lmm Management\""')

It works.

Changed File path to include a space also

Run('"C:\Users\Pat\Desktop\Setup Install\setup.exe" /s /v"/qn USERNAME="Lmm" AGREETOLICENSE=Yes COMPANYNAME=\"Lmm Management\""')

It Works?  Somehow

On 32bit windows 7 machine accessing the installer on server i tried

Run('"\\pafile\WindebtXL\WindebtXLPA\WinDebt SQL\Setup\setup.exe" /s /v"/qn USERNAME="Lmm" AGREETOLICENSE=Yes COMPANYNAME=\"Lmm Management\""')

It does not work :(

send("#r")
Send('"\\pafile\WindebtXL\WindebtXLPA\WinDebt SQL\Setup\setup.exe" /s /v"/qn USERNAME="Lmm" AGREETOLICENSE=Yes COMPANYNAME=\"Lmm Management\""{Enter}')

Oh hey it works.  But am really trying to avoid having run window pop up and watch the text scroll along.

I just don't understand what is different between those 2 lines.  I am about to try cutting out  the params and jus end at the exe.  But if that works i will ned to find a way to set those parameters anyway.  Thanks for all the suggestions by the way.  Keep them coming.  I am willing to try just about everything.

Link to comment
Share on other sites

jguinch your a geniuos.  changed my command to

ShellExecute('\\pafile\WindebtXL\WINDEB~1\WinDeb~1\Setup\setup.exe', '/v" /qn /L*v "C:\wdins.log" USERNAME="Lmm" AGREETOLICENSE=Yes COMPANYNAME=\"Lmm Management\"',"")

And it worked.  Couple questions about it.  would it be better to use shellexecute wait?  And what makes this different then run?  Sorry if its a stupid question, but jsut trying to learn.

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