0

I've searched in many posts that already deal with this kind of issue but I'm still not able to make it work in my case.

I'm trying to create a link file to Launch a bat file with cmd.exe (because the bat file launch a service in spy/console mode so the console has to be shown). The bat file is created before the install process of the service. The link file is created in Windows Start Menu while installing process, so it can embed the path where the exe file of the service is installed.

As the root path will be linked to cmd.exe, I need to pass the path of the exe of the service as an argument of the bat file, itself being an argument of the cmd.exe file...

I've tried the syntax given as a solution in this threat : correct quoting for cmd.exe for multiple arguments

Spaces in Program Path + parameters with spaces :
cmd /k ""c:\batch files\demo.cmd" "Parameter 1 with space" "Parameter2 with space""

So in my case, I've writen:

cmd /k ""C:\Program Files (x86)\Company\Licenses Server\Debug Mode.bat" "C:\Program Files (x86)\Company\Licenses Server\""

Here is the content of the "Debug Mode.bat" file :

@ECHO off
net stop company.service
START %~f1ServiceFile.exe /console spymode
net start company.service
@ECHO On

But when I launch the link file, I get the message:

Windows cannot find C:\Program...

There must be a "quote" problem but I've tried a lot of different syntaxes and I cannot figure out what goes wrong here...

Community
  • 1
  • 1
BenDev
  • 349
  • 3
  • 18
  • 3
    I would try with `START "" "%~f1ServiceFile.exe" /console spymode` – MC ND Feb 14 '17 at 12:23
  • Thanks a lot @MC ND, it works well with START "" "%~f1ServiceFile.exe" /console spymode Well, it keeps opened the first cmd console launched, but the console for spy mode is well displayed too so that's not a problem ;) – BenDev Feb 14 '17 at 14:00
  • Ok, I've found the final solution that works for me: "%~f1ServiceFile.exe" /console spymode So without START "" at the beginning. – BenDev Feb 14 '17 at 14:04

0 Answers0