ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Shell command ignores variable (https://www.excelbanter.com/excel-programming/435307-shell-command-ignores-variable.html)

Paul

Shell command ignores variable
 
Hi,

I have a macro that uses psexec to launch presentations on remote machines,
in the macro I capture the workstation name and the file name from cells and
pass it to the psexec command line, only problem is the command ignores the
first variable.

WKSTN = "\\" & Range("N8").Text
TargetFile = Range("B7").Value

Shell ("c:\PRES\psexec & WKSTN -e -i -d ""c:\program files\microsoft
office\office11\pptview.exe"" /S c:\pres\" & TargetFile)

If I amend to
Shell ("c:\PRES\psexec \\WorkstationName -e -i -d ""c:\program
files\microsoft office\office11\pptview.exe"" /S c:\pres\" & TargetFile)
It works fine

Using & WKSTN the variable does not get passed to the command line and
psexec tries to launch & WKSTN

Any help appreciated

Regards and thanks

Paul


Rick Rothstein

Shell command ignores variable
 
You didn't implement the concatenation correctly. Try it this way...

Shell ("c:\PRES\psexec " & WKSTN & "-e -i -d ""c:\program files\microsoft
office\office11\pptview.exe"" /S c:\pres\" & TargetFile)

--
Rick (MVP - Excel)


"Paul" wrote in message
...
Hi,

I have a macro that uses psexec to launch presentations on remote
machines, in the macro I capture the workstation name and the file name
from cells and pass it to the psexec command line, only problem is the
command ignores the first variable.

WKSTN = "\\" & Range("N8").Text
TargetFile = Range("B7").Value

Shell ("c:\PRES\psexec & WKSTN -e -i -d ""c:\program files\microsoft
office\office11\pptview.exe"" /S c:\pres\" & TargetFile)

If I amend to
Shell ("c:\PRES\psexec \\WorkstationName -e -i -d ""c:\program
files\microsoft office\office11\pptview.exe"" /S c:\pres\" & TargetFile)
It works fine

Using & WKSTN the variable does not get passed to the command line and
psexec tries to launch & WKSTN

Any help appreciated

Regards and thanks

Paul



Paul

Shell command ignores variable
 
Rick

Thanks for your prompt response, it's amazing what a couple of missing
quotation marks and an ampersand can do to a line of code....now works
Thanks

"Rick Rothstein" wrote in message
...
You didn't implement the concatenation correctly. Try it this way...

Shell ("c:\PRES\psexec " & WKSTN & "-e -i -d ""c:\program files\microsoft
office\office11\pptview.exe"" /S c:\pres\" & TargetFile)

--
Rick (MVP - Excel)


"Paul" wrote in message
...
Hi,

I have a macro that uses psexec to launch presentations on remote
machines, in the macro I capture the workstation name and the file name
from cells and pass it to the psexec command line, only problem is the
command ignores the first variable.

WKSTN = "\\" & Range("N8").Text
TargetFile = Range("B7").Value

Shell ("c:\PRES\psexec & WKSTN -e -i -d ""c:\program files\microsoft
office\office11\pptview.exe"" /S c:\pres\" & TargetFile)

If I amend to
Shell ("c:\PRES\psexec \\WorkstationName -e -i -d ""c:\program
files\microsoft office\office11\pptview.exe"" /S c:\pres\" & TargetFile)
It works fine

Using & WKSTN the variable does not get passed to the command line and
psexec tries to launch & WKSTN

Any help appreciated

Regards and thanks

Paul




All times are GMT +1. The time now is 12:01 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com