Jump to content
LisHawj

WMIC command error - need advices

Recommended Posts

LisHawj

Hi everyone,

I did search on the forum and found much useful information on how to run WMIC.exe with Auotit, but I am still unable to get my script working.  I simply need to grab the file or product version of Enase (Enstart64.exe),  and I have tried it every way I was shown in articles/posts on I have found on the topic.  Still no go.  Can someone take a glance and tell me what the heck I am doing wrong with this command?  Thank you.

Running this from Windows CMD works: wmic.exe datafile where name='C:\\Windows\System32\\Enstart64.exe' GET version

 

$var1 = "C:\Windows\System32\Enstart64.exe"
$var2 = "GET version"
$var3 = "datafile where name='"


$iVer =ShellExecuteWait("wmic.exe", $var3, $var1 & $var2)
MsgBox(0,"", $iVer)

$iVer =RunWait(@ComSpec & " /c " & "wmic.exe " & $var3 & $var1 & $var2, @SystemDir, @SW_SHOW)
MsgBox(0,"", $iVer)

 

Share this post


Link to post
Share on other sites
JLogan3o13

A couple of things:

  • "Still no go" - doesn't help us a lot. Are you getting an error, or is nothing returned, etc.
  • If you take your ShellExecuteWait command and output it to the console, does it look like what you would expect?
  • If you change the /c to /k in your RunWait command to keep the command line window open, do you get any error or useful output?

Please help us help you ;)


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites
Jos
29 minutes ago, LisHawj said:

$iVer =ShellExecuteWait("wmic.exe", $var3, $var1 & $var2)

There is a space missing between $var1 & $var2?

30 minutes ago, LisHawj said:

$iVer =RunWait(@ComSpec & " /c " & "wmic.exe " & $var3 & $var1 & $var2, @SystemDir, @SW_SHOW)

... and here between all $var?s ?

Jos


SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
ripdad

And ... double slashes with double quotes -- closed with single quotes.

$var1 = '"C:\\Windows\\System32\\Enstart64.exe"'

 


"The mediocre teacher tells. The Good teacher explains. The superior teacher demonstrates. The great teacher inspires." -William Arthur Ward

Share this post


Link to post
Share on other sites
LisHawj
Posted (edited)
$var1 = "C:\\Windows\\System32\\Enstart64.exe"
$var2 = " GET version"
$var3 = " datafile where name='"

$iVer =ShellExecuteWait("wmic.exe", $var3 & $var1 & $var2, @SW_SHOW)
MsgBox(0,"", $iVer)

$iVer =RunWait(@ComSpec & " /k " & "wmic.exe" & $var3 & $var1 & $var2, @SystemDir, @SW_SHOW)
MsgBox(0,"", $iVer)

Ok, so I'm still having trouble after reviewing all the comments and ensuring the "spacing" is all there.  The program is reporting the following error.

ERROR:

Description = Invalid Query

Error.JPG

Edited by LisHawj

Share this post


Link to post
Share on other sites
ripdad
$var1 = '"C:\\Windows\\System32\\Enstart64.exe"'
$var2 = ' GET version'
$var3 = ' datafile where name='

RunWait(@ComSpec & ' /k wmic.exe' & $var3 & $var1 & $var2, @SystemDir, @SW_SHOW)

 


"The mediocre teacher tells. The Good teacher explains. The superior teacher demonstrates. The great teacher inspires." -William Arthur Ward

Share this post


Link to post
Share on other sites
JLogan3o13
$var1 = "C:\\Windows\\System32\\Enstart64.exe"
$var2 = " GET version"
$var3 = " datafile where name='"

ConsoleWrite("wmic.exe" & $var3 & $var1 & $var2 & @CRLF)

Does the output from this ^^^ look the same as how you would type it manually in a command prompt?


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites
JLogan3o13

Trying to get him to the same point :)

 


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites
LisHawj

@Jos and @JLogan3o13,

Thank you for your patience, LOL.  I know you run into folks like me all the time, but I applaud your generosity with your knowledge.  Please keep making new scripter like myself work harder to learn the trade while at the same time nudging us in the right direction.  I have FOUND the culprit with your help!  Thank you!!!

$var1 = "C:\\Windows\\System32\\Enstart64.exe'"
$var2 = " GET version"
$var3 = " datafile where name='"

$iVer =RunWait(@ComSpec & " /k " & "wmic.exe" & $var3 & $var1 & $var2, @SystemDir, @SW_SHOW)
MsgBox(0,"", $iVer)

 

  • Like 1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×