-1

I am running the following command in cmd for which I am able to get the log successfully.

cd C:\Users\sriram\AppData\Local\Temp\license1.1.4

C:\Users\sriram\AppData\Local\Temp\license1.1.4>lsmon.exe testprovilic.muc.company> C:\Users\sriram\AppData\Local\Temp\license1.1.4\usage.log

Above command will generate the logs in the usage log file. But I created a batch file as below for which it is giving me an error testprovilic.muc.company not found

@ECHO off

SET variable=C:\Users\s.d.vaidyanathan\AppData\Local\Temp\usage.log

START "C:\Users\s.d.vaidyanathan\AppData\Local\Temp\license1.1.4"lsmon.exe testprovilic.muc.company> "%variable%"

Could you please help me solve this issue.

Thanks and Regards, Sriram

3 Answers3

0

You need to add the "cd C:\Users\sriram\AppData\Local\Temp\license1.1.4" to the batch file. Or use the full path to the file like:

C:\Users\sriram\AppData\Local\Temp\license1.1.4\testprovilic.muc.company

So you would have ..

@ECHO off
cd C:\Users\sriram\AppData\Local\Temp\license1.1.4
SET variable=C:\Users\s.d.vaidyanathan\AppData\Local\Temp\usage.log
START "C:\Users\s.d.vaidyanathan\AppData\Local\Temp\license1.1.4"lsmon.exe testprovilic.muc.company> "%variable%"

or you could

@ECHO off
SET variable=C:\Users\s.d.vaidyanathan\AppData\Local\Temp\usage.log
START "C:\Users\s.d.vaidyanathan\AppData\Local\Temp\license1.1.4"lsmon.exe C:\Users\sriram\AppData\Local\Temp\license1.1.4\testprovilic.muc.company> "%variable%"
LuvnJesus
  • 631
  • 4
  • 9
  • Hello @LuvnJesus, I tried with cd as well I am getting the same error. actually testprovilic.muc.company is the server which I am passing to the lsmon.exe. Is there any specific format to pass it through bat file? – sriram vaidyanathan Feb 03 '16 at 04:57
  • Why is lsmon.exe outside the quotes and why is there no slash between the path and lsmon.exe? – Carey Gregory Feb 03 '16 at 04:57
  • @CareyGregory I make that folder as the default and and then I try to run exe whicn is present inside that folder. – sriram vaidyanathan Feb 03 '16 at 05:48
0

This doesn't work:

"C:\Users\s.d.vaidyanathan\AppData\Local\Temp\license1.1.4"lsmon.exe 

The whole path needs to be in quotes and there needs to be a backslash after the last folder name.

Change it to this:

"C:\Users\s.d.vaidyanathan\AppData\Local\Temp\license1.1.4\lsmon.exe"
Carey Gregory
  • 6,836
  • 2
  • 26
  • 47
0

Open a command prompt window, type set and press key RETURN or ENTER to run this command. You get displayed all predefined environment variables with their current values. You can see TEMP, USERPROFILE and USERNAME.

Windows command line has a help. The command to get help is help, yes really. Try it out! You need help on command CD, enter in command prompt window help cd or alternatively cd /?. You need help on command SET and START, run help set or set /? and help start or start /?. All internal commands of cmd.exe and nearly all console applications support the parameter /? and output 1 or more help pages on running the command with this parameter.

You need a better overview of standard Windows commands? See Microsoft's command-line reference and SS64's command line reference.

I assume that sriram is your user account and s.d.vaidyanathan is the user account of someone else. By default a standard user has no permissions to access folders and files in a different user's profile than the own profile since Windows Vista. That means, you logged in as sriram can't access the files and folders of C:\Users\s.d.vaidyanathan because of missing permissions to do so. It would be necessary to use command Runas to run the batch file with account s.d.vaidyanathan.

@echo off

rem Execute lsmon.exe from license1.1.4 in my folder for temporary
rem files and folders and write the log file also into this folder.

"%TEMP%\license1.1.4\lsmon.exe" testprovilic.muc.company >"%TEMP%\license1.1.4\usage.log"

Note: Double quotes must be used around path AND file name. Just double quoting parts of a file name with path may or may not work depending on error correction and how the application is written. For details see answer on set environment variables with spaces.

See also the Microsoft article Using command redirection operators.

And regarding right usage of command START not really needed here see for example answer on How to call a batch file in the parent folder of current batch file?

Mofi
  • 46,139
  • 17
  • 80
  • 143