1.

Solve : batch file not taking parameter properly?

Answer»

I am passing one parameter to batch file which is date time in following format.
EventParam="01/08/09,02:38:42PM-01/08/09,02:38:58PM"
System.Diagnostics.Process.Start("D:\param.bat",EventParam)
When I am CALLING batch file with process.start it takes the EventParam argument as "01/08/09" only. It doesn't tale the whole string. I guess this problem is because of commas in between . Any solution to this?



Code: [Select]
@echo off

echo %1

cscript C:\Windows\system32\eventquery.vbs /s RemoteMachineIP /u DomainName\userName /p Password /fi "Type eq Error" /fi "Datetime eq %1" /l "onlineavl services" >> Eventlogs.log

Yes.
What is the EXACT code you use?
Use the code button on the tool bar above so we can see
all spacing and layout just as it is in the bat file. My batch file is

@echo off

echo %1

cscript C:\Windows\system32\eventquery.vbs /s remoteMachineIP /u NW\username /p password /fi "Type eq Error" /fi "Datetime eq %1" /l "onlineavl services" >> Eventlogs.logHave you tested the script?
You have @echo off
This is a poor preactice if you have not yetproven the file works.
Also, can you break this into smaller steps?
And do you test the %1 parameter to see if it is a valid VALUE?
Instead of USING >> to a file, did you first confirm that the script was working?
Batch files, or any kind of programming becomes easier
if you can break it down into smaller bits.
If possible, test each part by itself. Then you can see where the problem is.

Hint: try putting the complex string parameter into a file and ave the program
read the parameter from the file. But not from of the command line.

The command interpreter treys to parse things on the command line and may not pass the entire string to the program as the first parameter. The way to avoid this is to have a program parse the string with no help of the command interpreter. Put the string in a file.

Yes, there are other was to fix the problem.
My pint of view is just make it simple and it will WORK.the script is included with Windows, so one can assume that that works.

However... what is up with this particular part:



Quote


cscript C:\Windows\system32\eventquery.vbs /s remoteMachineIP /u NW\username /p password /fi "Type eq Error" /fi "Datetime eq %1" /l "onlineavl services" >> Eventlogs.log

Some of the parameters passed to the script appear to be the same PROVIDED with the documentation as placeholders for actual values.

If it's the local machine, this should work sufficiently:


Code: [Select]eventquery.vbs /fi "Type eq Error" /fi "Datetime eq %1" /l "onlineavl services" >> Eventlogs.log

if it isn't the local machine, and/or it requires a password, you'll need to change the placeholder text.


Discussion

No Comment Found