View Full Version : Problem with using wmic commands in a batch file
07-16-2009, 12:49 PM
Hey, I am trying to check if user exists on a Windows system by running the following command using the "Execute script/batch file" option
wmic useraccount get /format:value | findstr $USER$
however that command just hangs indefinitely and the install freezes. If I change it to
wmic "useraccount get /format:value | findstr $USER$"
It still hangs. If I change it to
"wmic useraccount get /format:value | findstr $USER$"
It does not hang but I get the error "The System cannot find the path specified".
Is there some way you need to use wmic to get it to work or is there another way to check that a user exists in a Windows system?
Thanks for the help,
07-17-2009, 02:30 AM
The following command works:
wmic useraccount get /format:value | findstr "$USER$"
this is like your hanging command but prevents error in case of space in $USER$ name.
Anyway this command (in execute script) works, I guess it does not hang for you but only takes a long time answering ...
You can try by using execute script with wmic /? for example and checking the result of $EXECUTE_STDOUT$.
07-17-2009, 12:14 PM
Well I'm not sure how long is long, but I just let it go for a full hour and it still was hanging. If nothing else that is far to long to go into a customer product.
When I did wmic /? it still hung forever. This is what my exact window looks like:
Am I doing something wrong since you said this is supposed to work?
07-17-2009, 01:02 PM
Well, there is no reason for which the wmic should hang... most likely there's some kind of issue when called from within IA. Personally, I don't like the Execute Batch/Script, and I tend to replace it with Execute Command. I would try to execute the following command:
$SYSTEM_32$$/$Wbem$/$wmic.exe useraccount get /format:value | $SYSTEM_32$$/$findstr.exe "$USER$"
If this doesn't work then please try execute the following:
CMD /C $SYSTEM_32$$/$Wbem$/$wmic.exe useraccount get /format:value | $SYSTEM_32$$/$findstr.exe "$USER$"
And if this doesn't work either then I would recommend that in your installer you create a .bat file that you would install and call by using Execute Target. That should do the trick.
07-17-2009, 02:06 PM
Thanks for those suggestions, but unfortunately none of them worked and they all hung indefinitely as well.
My batch file looked like this
wmic useraccount get /format:value | findstr drew
The batch file ran correctly when I just ran it by itself standalone.
With all of these different solutions causing the same problem I'm beginning to think it might be a system error. I'm on Windows XP SP2. Could this be an issue with that and not an IA bug? Perhaps a permission issue?
07-18-2009, 06:20 AM
Well, if you do put a pause in your .bat file I guess that the installer will wait indefinitely for you to press a key... but you no longer have the input to the bat when launched from within IA.
03-04-2011, 03:29 PM
I know this will sound crazy, but i was having intermittent problem with this when using batch scripts before just typing it from command line.
I found if i redirected input from nul it would operate normally again.. e.g.
wmic process get <nul
Powered by vBulletin® Version 4.2.0 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.