Using authorization and starting the service

Hello. Thank you for the convenient and simple program, but during the setup process some questions arose that I couldn’t figure out on my own

1. Is it possible in Windows to use authorization using two passwords for two different devices via a bat file, without using python, powershell and others?

2. When running the program as a service, Windows does not process the auth.bat authorization file. When the service is disabled and started manually, the authorization file is used and connections are made according to the parameters entered in it

In both cases the work is done on windows 10, the program was purchased

Thanks in advance for your answer

#2

  1. Yes in the example auth.bat file in the https://www.virtualhere.com/authorization page you can just add some "and"conditions to the first test to test e.g %1 which is Vendor ID of the device etc.. However batch files dont have the AND operator :o So you need to basically use workarounds e.g https://stackoverflow.com/questions/2143187/logical-operators-and-or-in-dos-batch.

     

  2. I think the reason is that the ClientAuthorization entry in your config.ini file is probably pointing to a file which is inaccessible when running as a service e.g maybe it pointing to a network drive file? You should have all batch files on the c drive usually in the same directory as the vhusbdwin64.exe file. You should also specify the full path to the batch file with forward slashes.     

   e.g for example on my test machine windows virtualhere server in the config.ini file: (all one line)

   ClientAuthorization=C:/Users/mail/downloads/auth.bat "$VENDOR_ID$" "$PRODUCT_ID$" "$CLIENT_ID$" "$CLIENT_IP$" "$PRODUCT_SERIAL$" "$PASSWORD$" "$DEVPATH$" "$NICKNAME$" "$NUM_BINDINGS$"

   And the vhusbdwin64.exe is in C:/Users/mail/downloads/
    

    

#3

I apologize for the long answer
2. The path is local not network. Similarly I moved the program folder to downloads and started the service there the problem remained.

ClientAuthorization=C:/Users/Nero/Downloads/VirtualHere/auth.bat "$VENDOR_ID$" "$PRODUCT_ID$" "$CLIENT_ID$" "$CLIENT_IP$" "$PRODUCT_SERIAL$" "$PASSWORD$" "$DEVPATH$" "$NICKNAME$" "$NUM_BINDINGS$"
 

 But I noticed that I use the clientid search for this example creating user authorization for multiple users with unique passwords | VirtualHere

I tried it in auth.bat specify the full path to users.txt but in any case, nothing worked and the output in log.txt

Thu Nov 28 15:44:48 2024 LOG_INFO    >>> Starting VirtualHere USB Server v4.7.0 (Built: Oct 15 2024, 15:39:27)<<< 
Thu Nov 28 15:44:48 2024 LOG_INFO    Using configuration C:\Users\Nero\Downloads\VirtualHere\config.ini 
Thu Nov 28 15:44:48 2024 LOG_INFO    Server licensed to=XXX max_devices=unlimited 
Thu Nov 28 15:44:48 2024 LOG_INFO    Listening on all network interfaces at TCP port 7575 (IPv6 dual-stack) 
Thu Nov 28 15:44:49 2024 LOG_WARNING Loading string descriptor for device on port 1 failed, присоединенное к системе устройство не работает. (0x0000001f) 
Thu Nov 28 15:44:49 2024 LOG_WARNING Loading string descriptor for device on port 1 failed, присоединенное к системе устройство не работает. (0x0000001f) 
Thu Nov 28 15:44:49 2024 LOG_WARNING Loading string descriptor for device on port 2 failed, присоединенное к системе устройство не работает. (0x0000001f) 
Thu Nov 28 15:44:50 2024 LOG_WARNING Loading string descriptor for device on port 2 failed, присоединенное к системе устройство не работает. (0x0000001f) 
Thu Nov 28 15:44:50 2024 LOG_INFO    Found High speed device [045b:0209] "0x045b, 0x0209" at address 2 
Thu Nov 28 15:44:50 2024 LOG_INFO    Found High speed device [2109:3431] "0x2109, USB2.0 Hub" at address 4 
Thu Nov 28 15:44:50 2024 LOG_INFO    Found High speed device [045b:0209] "0x045b, 0x0209" at address 6 
Thu Nov 28 15:44:50 2024 LOG_INFO    Found Full speed device [046d:c52b] "Logitech, USB Receiver" at address 25 
Thu Nov 28 15:44:50 2024 LOG_INFO    Found Super speed device [045b:0210] "0x045b, 0x0210" at address 8 
Thu Nov 28 15:44:50 2024 LOG_INFO    Found High speed device [2109:3431] "0x2109, USB2.0 Hub" at address 5 
Thu Nov 28 15:44:50 2024 LOG_INFO    Found Super speed device [045b:0210] "0x045b, 0x0210" at address 10 
Thu Nov 28 15:44:50 2024 LOG_INFO    Found High speed device [2109:3431] "0x2109, USB2.0 Hub" at address 1 
Thu Nov 28 15:44:50 2024 LOG_INFO    Found High speed device [2109:3431] "0x2109, USB2.0 Hub" at address 16 
Thu Nov 28 15:44:50 2024 LOG_INFO    Found Super speed device [0951:1666] "Kingston, DataTraveler 3.0" at address 22 
Thu Nov 28 15:45:09 2024 LOG_INFO    192.168.8.142 connected as connection 1 (Standard TCP) 
Thu Nov 28 15:45:14 2024 LOG_INFO    192.168.9.238 connected as connection 2 (Standard TCP) 
Thu Nov 28 15:45:16 2024 LOG_ERR     Error binding device 22 [0951:1666] to connection 2, BIND_PASSWORD_REQUIRED 
Thu Nov 28 15:45:17 2024 LOG_ERR     Error binding device 22 [0951:1666] to connection 2, BIND_UNAUTHORIZED 
Thu Nov 28 15:45:20 2024 LOG_ERR     Error binding device 25 [046d:c52b] to connection 2, BIND_PASSWORD_REQUIRED 
Thu Nov 28 15:45:21 2024 LOG_ERR     Error binding device 25 [046d:c52b] to connection 2, BIND_UNAUTHORIZED

 

Auth.bat looks like this

@echo off
rem Example script for performing basic user authorization for virtualhere in windows
rem Also includes a simple password protection mechanism for accessing a device
rem Return 3 if the user needs to provide a username AND password (or the password is incorrect) to use the device
rem Return 2 if the user needs to provide only a password (or the password is incorrect) to use the device
rem Return 1 if the user is allowed to access this device
rem Return 0 if the user is not allowed to access this device
rem Parameters are passed in as:
rem %1 = VENDOR_ID
rem %2 = PRODUCT_ID
rem %3 = CLIENT_ID
rem %4 = CLIENT_IP
rem %5 = PRODUCT_SERIAL
rem %6 = PASSWORD
rem %7 = DEVPATH
rem %8 = NICKNAME
rem %9 = NUM_BINDINGS
rem for help debugging this script, look in the file log.txt to see the arguments passed in
rem and the result of the IF statements below
echo %1 > log.txt
echo %2 >> log.txt
echo %3 >> log.txt
echo %4 >> log.txt
echo %5 >> log.txt
echo %6 >> log.txt
echo %7 >> log.txt
echo %8 >> log.txt
echo %9 >> log.txt
rem "mypassword" = "34819d7beeabb9260a5c854bc85b3e44" as an MD5 hash
rem go here https://passwordsgenerator.net/md5-hash-generator to determine the MD5 hash for the password you want to use

IF %6=="81dc9bdb52d04dc20036dbd8313ed055" (
 echo "Password ok" >> log.txt
) ELSE (
 echo "Password invalid" >> log.txt
 exit 2
)
FINDSTR %3 users.txt >Nul
IF 0==%errorlevel% (
 EXIT 1
) ELSE (
 EXIT 0
)

 

 

#4

Run the batch file directly in the cmd.exe command prompt and make sure it doesnt have any syntax errors, run it like this

C:/Users/Nero/Downloads/VirtualHere/auth.bat "1" "2" "3" "4" "5" "6" "7" "8" "9"

AND put the full path to users.txt in the batch file