Link to home
Start Free TrialLog in
Avatar of jalymo
jalymo

asked on

Shell cmd not working

The following Shell command does nothing when executed:

x = Shell("net user /domain xyz >c:\mydocs\valid\lanuserhold\xyz.txt", 0)

If I execute the same command via bat file it works:

x = Shell("c:\mydocs\valid\LanUserHold\testbat.bat", 0)  

The test.bat file contains:

net user /domain xyz >c:\mydocs\valid\lanuserhold\xyz.txt
exit


Although it is executed in an Access module, I figured the VB code area would be a better place to post question. Any ideas?
Avatar of Erick37
Erick37
Flag of United States of America image

x = Shell("c:\command.com" & " net user...

or

x = Shell(Environ("COMSPEC") & " net user ...
Avatar of jalymo
jalymo

ASKER

Erick37 --

Tried both but they did not work.  As I am using an NT workstation, I referenced "c:\winnt\system32\command.com" for your first option.

I tried vbNormalFocus to see if there were any error messages, but the sceen whips by so fast, I can't see anything.
ASKER CERTIFIED SOLUTION
Avatar of mmips
mmips

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
forgot

x = Shell("c:\winnt\system32\cmd.com /k" & " net user...

Add the /k to keep the window open after executing to see your error messages...
Avatar of jalymo

ASKER

way to go mmips --- the cmd.exe did it!