Author Topic: COMSPEC  (Read 396 times)

JTaylor

  • Pundit
  • *****
  • Posts: 922
    • Data & Stuff Inc.
COMSPEC
« 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

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)

 



 

stanl

  • Pundit
  • *****
  • Posts: 796
Re: COMSPEC
« Reply #1 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

JTaylor

  • Pundit
  • *****
  • Posts: 922
    • Data & Stuff Inc.
Re: COMSPEC
« Reply #2 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

td

  • Tech Support
  • *****
  • Posts: 2619
    • WinBatch
Re: COMSPEC
« Reply #3 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.
"Success is a lousy teacher. It seduces smart people into thinking they can't lose."
  - Bill Gates


JTaylor

  • Pundit
  • *****
  • Posts: 922
    • Data & Stuff Inc.
Re: COMSPEC
« Reply #4 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

td

  • Tech Support
  • *****
  • Posts: 2619
    • WinBatch
Re: COMSPEC
« Reply #5 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.
"Success is a lousy teacher. It seduces smart people into thinking they can't lose."
  - Bill Gates


JTaylor

  • Pundit
  • *****
  • Posts: 922
    • Data & Stuff Inc.
Re: COMSPEC
« Reply #6 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

td

  • Tech Support
  • *****
  • Posts: 2619
    • WinBatch
Re: COMSPEC
« Reply #7 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.
"Success is a lousy teacher. It seduces smart people into thinking they can't lose."
  - Bill Gates


JTaylor

  • Pundit
  • *****
  • Posts: 922
    • Data & Stuff Inc.
Re: COMSPEC
« Reply #8 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

JTaylor

  • Pundit
  • *****
  • Posts: 922
    • Data & Stuff Inc.
Re: COMSPEC
« Reply #9 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

stanl

  • Pundit
  • *****
  • Posts: 796
Re: COMSPEC
« Reply #10 on: June 24, 2018, 07:42:39 am »
Out of curiosity.... would have setting it up as a shortcut revealed the issues earlier

JTaylor

  • Pundit
  • *****
  • Posts: 922
    • Data & Stuff Inc.
Re: COMSPEC
« Reply #11 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