You are not logged in.

#1 31 Oct 2020 11:36

lazna
Member
Registered: 15 Apr 2020
Posts: 12

The system cannot find the path specified

Utilizing cmdtwain and thebat! to half-automatize documents scanning and sending in script:

@echo off
set "rcpt=user@host.com"
::
REM == If old protokol exist, delete it ========================================
if exist "c:\Users\user\Desktop\protokol.jpg" del "c:\Users\user\Desktop\protokol.jpg" >NUL 2>&1
::
REM == Scan protocol new protocol =========================================
"C:\Program Files (x86)\GssEziSoft\CmdTwain\cmdtwain.exe" -q -c 600 100 "c:\Users\user\Desktop\protokol.jpg"
::
REM == Open new mail editor window for writing and attach protocol file ==============
"C:\Program Files\The Bat!\thebat64.exe" /NOLOGO /MAILU=User;to=%rcpt%;subject=Protokol;edit;attach="c:\Users\user\Desktop\protokol.jpg"

last line of script failed and give me %SUBJ%. When have @echo on, and copy last line of script from cmd window and paste it back to original cmd window and pres ENTER, than successfully execute without any err message. Whan am I doing wrong?

Offline

#2 31 Oct 2020 14:38

RG
Member
From: Minnesota
Registered: 18 Feb 2010
Posts: 362

Re: The system cannot find the path specified

Are you showing us the entire script?
I notice that there is a "!" in the last line.
If you have delayed expansion enabled that "!" will be lost.


Windows Shell Scripting and InstallShield

Offline

#3 31 Oct 2020 17:00

Simon Sheppard
Admin
Registered: 27 Aug 2005
Posts: 1,130
Website

Re: The system cannot find the path specified

Those semicolons are delimiters, so CMD will treat them just like spaces unless the entire string is placed in quotes
https://ss64.com/nt/syntax-esc.html

This means you will also have to escape or double up the quotes in the final pathname, although as it does not include any spaces you could just leave those quotes out.

Offline

#4 01 Nov 2020 10:28

lazna
Member
Registered: 15 Apr 2020
Posts: 12

Re: The system cannot find the path specified

RG wrote:

Are you showing us the entire script?
I notice that there is a "!" in the last line.
If you have delayed expansion enabled that "!" will be lost.

Whole code is displayed, delayed expansion not employed.

Offline

#5 01 Nov 2020 10:30

lazna
Member
Registered: 15 Apr 2020
Posts: 12

Re: The system cannot find the path specified

Simon Sheppard wrote:

Those semicolons are delimiters, so CMD will treat them just like spaces unless the entire string is placed in quotes
https://ss64.com/nt/syntax-esc.html

This means you will also have to escape or double up the quotes in the final pathname, although as it does not include any spaces you could just leave those quotes out.

You are right, this variant work fine:

"C:\Program Files\The Bat!\thebat64.exe" /NOLOGO /MAIL"U=User;to=%rcpt%;subject=Protokol;edit;attach="c:\Users\user\Desktop\protokol.jpg^""

thanks

Last edited by lazna (01 Nov 2020 11:01)

Offline

#6 01 Nov 2020 12:14

Simon Sheppard
Admin
Registered: 27 Aug 2005
Posts: 1,130
Website

Re: The system cannot find the path specified

lazna wrote:
Simon Sheppard wrote:

Those semicolons are delimiters, so CMD will treat them just like spaces unless the entire string is placed in quotes
https://ss64.com/nt/syntax-esc.html

This means you will also have to escape or double up the quotes in the final pathname, although as it does not include any spaces you could just leave those quotes out.

You are right, this variant work fine:

"C:\Program Files\The Bat!\thebat64.exe" /NOLOGO /MAIL"U=User;to=%rcpt%;subject=Protokol;edit;attach="c:\Users\user\Desktop\protokol.jpg^""

thanks

With that variant only the parts in bold are being quoted

"C:\Program Files\The Bat!\thebat64.exe" /NOLOGO /MAIL"U=User;to=%rcpt%;subject=Protokol;edit;attach="c:\Users\user\Desktop\protokol.jpg^""

for a path with spaces, you probably need:

"C:\Program Files\The Bat!\thebat64.exe" /NOLOGO /MAIL"U=User;to=%rcpt%;subject=Protokol;edit;attach=""c:\Users\user\this can have spaces\protokol.jpg"" "

Offline

Board footer

Powered by