WinBatch® Technical Support Forum

All Things WinBatch => WinBatch => Topic started by: JTaylor on June 22, 2018, 02:54:08 PM

Title: COMSPEC
Post by: JTaylor on June 22, 2018, 02:54:08 PM
Having run out of ideas I thought I would ask here...The following gives no errors but I get no output when run in WinBatch.  If I take the resulting b_param value and paste it into a command prompt it works as it should and I get the desired results (Chrome history).  I have tried both the 32 and 64-bit command prompts.   Guessing it may be a UAC issue but no real idea.  Suggestions?

Code (winbatch) Select


sql_exe = DirScript():"sqlite3.exe"

   h_path = ShortcutDir("Local AppData", 0, @TRUE):"Google\Chrome\User Data\Default\"

   cmd_32 = DirWindows(0):'syswow64\CMD.EXE'
   cmd_64 = DirWindows(0):'Sysnative\CMD.EXE'

   b_param = `/c "`:sql_exe:`" "%h_path%History" "SELECT datetime(last_visit_time/1000000-11644473600,'unixepoch','localtime'), urls.* FROM urls;" > hist.txt `

   comspec=Environment("COMSPEC")
   RunWait(comspec,b_param)
 
   clipput(b_param)
   message(comspec,b_param)

 



Title: Re: COMSPEC
Post by: stanl on June 23, 2018, 03:05:36 AM
I got the same results as you, but I ran the section in the script below I posted in 2001 that dealt with Chrome Browser [SQLite driver] and that worked. Gonna have to try putting the entire command into a .bat file


http://techsupt.winbatch.com/webcgi/webbatch.exe?techsupt/nftechsupt.web+WinBatch/OLE~COM~ADO~CDO~ADSI~LDAP/SQLite+Multi~Browser~History~Report.txt
Title: Re: COMSPEC
Post by: JTaylor on June 23, 2018, 08:16:54 AM
A batch file works as well.   That route is probably viable but not the ODBC or .NET route though.   Still hoping for a straight run from WinBatch but you know how it goes sometimes  :)

Also, I tried compiling & signing but still doesn't work.

Thanks.

Jim
Title: Re: COMSPEC
Post by: td on June 23, 2018, 10:17:47 AM
Have you tried switching the "/c" to "/K"?  There is some small possibility that the command window will contain some error information.  The cause of your problem may be as simple as not having the correct working directory set or it could be something completely different.  The fact that you don't get a WinBatch/WIL error suggests that the problem has something to do with cmd.exe being unhappy rather than WinBatch.
Title: Re: COMSPEC
Post by: JTaylor on June 23, 2018, 01:21:00 PM
I thought I remembered seeing a "K" used before but couldn't find any examples.  Guess I should have tried it anyway instead of thinking my thinking was wrong.  You are correct, as usual.  The error message is "The filename, directory name, or volume label syntax is incorrect."   I have full path names for everything but apparently one cannot put quotes around some paths.   If I take away the quotes from the sqlite exe and the output file name it works directly in WinBatch.    If my path has spaces then it fails even if I use quotes.   Probably a reason but at least I know a way to make it work.    Thanks.

Jim
Title: Re: COMSPEC
Post by: td on June 23, 2018, 03:32:56 PM
If you type "cmd /?" from a command prompt and scroll down a bit, you will get to a long explanation of when quotes are preserved on the command line.  Good luck sorting it out.
Title: Re: COMSPEC
Post by: JTaylor on June 23, 2018, 05:36:08 PM
Before I spend a lot of time trying to sort it out will it help explain why it works from the command line but not in WinBatch?   Seems like it would simply tell me what would or wouldn't work, which what I was doing did work from the command line.

Jim
Title: Re: COMSPEC
Post by: td on June 23, 2018, 06:13:04 PM
It depends.  The hope was that the help description would lead to an insight but maybe not.
Title: Re: COMSPEC
Post by: JTaylor on June 23, 2018, 06:55:53 PM
Okay.  I will see if it tells me anything and report back if any epiphanies occur.  Thanks again.

Jim
Title: Re: COMSPEC
Post by: JTaylor on June 23, 2018, 08:35:41 PM
Okay.   Again, as usual, you are correct.    It appears that the command line is treated differently if one uses /C or /K in regards to quote processing.   Something good for everyone to know, assuming I am the only one who doesn't, which often seems to the be the case with things :).   Rather than creating confusion I will simply suggest that anyone encountering problems along these lines read the cmd.exe help.

Jim
Title: Re: COMSPEC
Post by: stanl on June 24, 2018, 07:42:39 AM
Out of curiosity.... would have setting it up as a shortcut revealed the issues earlier
Title: Re: COMSPEC
Post by: JTaylor on June 24, 2018, 09:01:32 AM
Hmmmmmmmm....not sure if I understand.   Only the /K helped because it keeps the command window open so I could see the errors.   Since it was a command prompt error WinBatch didn't report anything and everything closed cleanly, as expected, when using /c.

Jim