This website uses cookies. By clicking Accept, you consent to the use of cookies. Click Here to learn more about how we use cookies.
Turn on suggestions
Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
- Revenera Community
- :
- InstallAnywhere
- :
- InstallAnywhere Forum
- :
- Re: Problem with using wmic commands in a batch file
Subscribe
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Subscribe
- Mute
- Printer Friendly Page
‎Jul 16, 2009
12:49 PM
Problem with using wmic commands in a batch file
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,
Drew
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,
Drew
(6) Replies
‎Jul 17, 2009
02:30 AM
Hello,
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$.
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$.
‎Jul 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?
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?
‎Jul 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:
If this doesn't work then please try execute the following:
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.
$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.
‎Jul 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
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?
My batch file looked like this
@echo off
wmic useraccount get /format:value | findstr drew
pause
dir c:\windows
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?
‎Mar 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
I found if i redirected input from nul it would operate normally again.. e.g.
wmic process get