Jump to content
UBot Underground

[Solved]How to Shell execute a .bat?


Recommended Posts

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

Link to post
Share on other sites

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%

Link to post
Share on other sites

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

Link to post
Share on other sites

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 directory

2. execute .bat

Edited by Psychotix
Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...