BAT FILE COMM Port mapping

dmanisit
dmanisit used Ask the Experts™
on
Hi everyone. I am running a POS that has barcode across Citrix and need a script to map the Comm port. I had this working on my test system. The script is below. When I call this script i am getting this error......  
Setting Baud Rate......
'MODE' is not recognized as an internal or external command,
operable program or Batch file.
launching application..
Press any key to continue...

@echo off
@if not "%OS%"=="Windows_NT" goto :EXIT
@if "%1"=="?" (set INFO=echo && set SEXIT=1) else (set INFO=rem && set SEXIT=0)

%INFO% *****************************
%INFO% Description: Maps appropriate COM and LPT port for Etreby devices
%INFO%                 and then launches C:\Policies\EtrebyDevices\POS.lnk
%INFO% *****************************
%INFO% Files: None.
%INFO% *****************************

@if "%SEXIT%"=="1" goto :EXIT

rem echo Mapping ports...

net use /persistent:no
net use com1 \\client\com1:


rem echo Setting Baud rate...


MODE COM1: BAUD=19200 PARITY=n DATA=8 STOP=1
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Commented:
Is mode.com present at c:\windows\system32 on this machine ... and is that on your path?  If not can you start it with

Start a cmd.exe prompt
mode
c:\windows\system32\mode?

Steve

Author

Commented:
I just verified that Mode.com is in the windows system32 dir. What do I need to change in my script?

Commented:
Does it work from a cmd.exe prompt like above then?

"'MODE' is not recognized as an internal or external command, operable program or Batch file" infers it just can't see it.

You could try:

c:\windows\system32\mode com1: ....

or
cd c:\windows\system32
mode com1: ....

It could be the user you are running it as does not have any rights to read/execute this file.  Not sure on it's use from Citrix, have seen mappings through with NET USE on COMx: but not needed to use MODE for it.

Still it hasn't got as far as running MODE command yet.

Steve
Acronis in Gartner 2019 MQ for datacenter backup

It is an honor to be featured in Gartner 2019 Magic Quadrant for Datacenter Backup and Recovery Solutions. Gartner’s MQ sets a high standard and earning a place on their grid is a great affirmation that Acronis is delivering on our mission to protect all data, apps, and systems.

Author

Commented:
No it doesnt work from above. However when i go to c:\Windows\System32 and type in mode it does

Commented:
ok... odd.  try this then!


pushd c:\windows\system32
  mode com1:
popd

Author

Commented:
ok, that works on the server. However i really dont understand where to put that in my script. I just took what you gave me and scripted that only to test

Commented:
Good, well just replace the line in your current batch then with:

pushd c:\windows\system32
  MODE COM1: BAUD=19200 PARITY=n DATA=8 STOP=1
popd

Steve

Author

Commented:
ok, here is the script now and I am getting the same error????

@echo off
@if not "%OS%"=="Windows_NT" goto :EXIT
@if "%1"=="?" (set INFO=echo && set SEXIT=1) else (set INFO=rem && set SEXIT=0)


%INFO% *****************************
%INFO% Description: Maps appropriate COM and LPT port for Etreby devices
%INFO%                 and then launches C:\Policies\EtrebyDevices\POS.lnk
%INFO% *****************************
%INFO% Files: None.
%INFO% *****************************

@if "%SEXIT%"=="1" goto :EXIT

rem echo Mapping ports...

net use /persistent:no
net use com1 \\client\com1:


rem echo Setting Baud rate...


pushd c:\windows\system32
  MODE COM1: BAUD=19200 PARITY=n DATA=8 STOP=1
popd

C:\ECC\POS.exe
Commented:
OK.  What do you get when you replace those three lines with this then to see what it can see.

echo Path is %path%
echo.
echo Current dir is %cd%
pushd c:\windows\system32
  echo Current dir is now %cd%
  dir mode.*
  MODE COM1: BAUD=19200 PARITY=n DATA=8 STOP=1
popd

Author

Commented:
Thank you

Commented:
Did you solve the problem in the end then?

Steve

Author

Commented:
I did, and thank you

Author

Commented:
@echo off
@if not "%OS%"=="Windows_NT" goto :EXIT
@if "%1"=="?" (set INFO=echo && set SEXIT=1) else (set INFO=rem && set SEXIT=0)


%INFO% *****************************
%INFO% Description: Maps appropriate COM and LPT port for Etreby devices
%INFO%                 and then launches C:\Policies\EtrebyDevices\POS.lnk
%INFO% *****************************
%INFO% Files: None.
%INFO% *****************************

@if "%SEXIT%"=="1" goto :EXIT

rem echo Mapping ports...

net use /persistent:no
net use com1 \\client\com1:


rem echo Setting Baud rate...


pushd c:\windows\system32
  MODE COM1: BAUD=19200 PARITY=n DATA=8 STOP=1
popd

C:\ECC\POS.exe

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial