I use a batch to execute locally in each client a robocopy
command, synchronize a folder and then starts an application which has a batch with its own pattern.
My next project is to convert this batch in a VBScript, using it directly from a remote shared folder instead to have the batch stored locally in each client.
Even if I'm not a good VBScript programmer, on the metrics, I'm almost set, but I'm stuck on porting the where
command to a VBScript.
In my batch file, I execute this command:
FOR /F "tokens=* USEBACKQ" %%F IN (`where /R C:\appfolder startapp.bat /F`) DO (
SET strAPP=%%F
)
In C:\appfolder
there is installed a software in each client and for some reasons, may be installed in wrong and different patterns, so the common startapp.bat
may have a different pattern in each client. For this reason the FOR
instance above help me to create a variable named %strapp%
which is used later in the batch to start the application.
Now, my VBScript is working using the exact pattern but without this "where command prevention", I would like to have the same feature that batch does, just to prevent that in the future the clients may have again a wrong installation in a non-common pattern.
e.g. in VBS using a strmsg menu, when the user from its client choose the right option, the VBScript starts the application:
objShell.Run("%comspec% /K C:\appfolder\startapp.bat & exit"), 1, True
strFlag = True
And it works, I tried to add the old where
command and set a variable adding & in each concatenate commands, all of those in one row with no luck....
e.g.
objShell.Run("%comspec% /K FOR /F "tokens=* USEBACKQ" %%F IN (`where /R C:\appfolder startapp.bat /F`) DO (SET strAPP=%%F) & %strapp% & exit"), 1, True
strFlag = True
I tried to use double quotes "" with no luck at all.