Psychotix 0 Posted February 28, 2012 Report Share Posted February 28, 2012 This is the function I need to do dir /b >a1list.txt That lists all files in a directory. I made that into a .bat file and did the following and nothing works. shell("cmd.exe C:\\cybertron\\ks\\km\\a1.bat ") I browsed the directory and found a1.bat, both including cmd.exe and without. I also tried dir /b >a1list.txt directly also nothing. Thanks Quote Link to post Share on other sites
Anonym 53 Posted February 28, 2012 Report Share Posted February 28, 2012 You need to specify the full path to cmd.exe, or by using environment variables to point to cmd.exe Quote Link to post Share on other sites
Anonym 53 Posted February 28, 2012 Report Share Posted February 28, 2012 Hmmm... I just had a look at the environment variables and there actually is one that points out cmd.exe , it's called "ComSpec" so accessing that environment variable is done using %comspec% Quote Link to post Share on other sites
k1lv9h 76 Posted February 28, 2012 Report Share Posted February 28, 2012 Hi, If you are going to use cmd.exe you should use this option "/C". Run cmd.exe /? in "Command Prompt" window for help on options. This shell code worked:shell("cmd.exe /C \"c:\\ubot\\shell-samples\\a1.bat\"") shell("\"c:\\ubot\\shell-samples\\a1.bat\"") shell("cmd.exe /C dir /b \"c:\\ubot\\shell-samples\" >dirlist.txt") Kevin Quote Link to post Share on other sites
Psychotix 0 Posted February 28, 2012 Author Report Share Posted February 28, 2012 (edited) Thanks it now works! Originally it didnt. Came up with an access denied error. Tried it again with Admin privilidges on Ubot and now works fine. Edit: The problem now is it actually wont go the my specified directory! Its just stuck there at C:\Program Files<86>\Ubot Studio\ I could make it do cd\mydirectory but cant make it execute like c:\mydirectory\a1.bat How to string 2 shell commands together? 1. go to directory2. execute .bat Edited February 29, 2012 by Psychotix Quote Link to post Share on other sites
k1lv9h 76 Posted February 29, 2012 Report Share Posted February 29, 2012 Hi, I use "&" between commands.ex.cd \dir1\dir2 & dir /b Kevin Quote Link to post Share on other sites
Psychotix 0 Posted February 29, 2012 Author Report Share Posted February 29, 2012 That works. Thanks again! Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.