Jump to content
UBot Underground

[Solved]Shell - Dealing with Different Paths for Same File (Excel.exe)


Recommended Posts

I have users that are running a bot on different PCs that have different paths to Excel 2010. Does anyone know how to format the shell command so that it will look in either one location or the other?

 

I've not been successful with using variables or functions within the shell statement. I've tried running:

 

shell("C:\\Program Files\\Microsoft Office\\Office14\\EXCEL.EXE")

shell("C:\\Program Files (x86)\\Microsoft Office\\Office14\\EXCEL.EXE")

 

but if the first one fails the bot stops and errors out.

 

Thanks,

 

Ken

Link to post
Share on other sites

Can't you let shell read the path from the Registry, or actually, there is symbol for the program directory. I can't remember the name of that variable though.

(this is a quite common error to do, I mean to assume that the name of the directory is "Program Files", while this in fact is not the case. In Sweden, for instance, the name of that directory in WindowsXP was "Program" and there were loads of problems coming from that due to the fact that Windows sometimes translated the names of directories to its 8 characters short form; PROGRAM~1

 

 

Google "environment variable" for program files, or something like that.

Link to post
Share on other sites

Ah, %ProgramFiles% :)

 

So if you swap the string to the path to something like

 

shell("%ProgramFiles%\\Microsoft Office\\Office14\\EXCEL.EXE")

 

 

It should work. It needs some work still, but something like that. You can check it by executing cmd.exe and then do

 

echo %ProgramFiles%

Link to post
Share on other sites

It's me again. :)

 

Actually this was much simpler than that. Check this out:

 

set(#x, $special folder("Program Files"), "Global")

 

 

Using this you should be able to concatenate the strings to get a correct path to Excel.

Link to post
Share on other sites

It's me again. :)

 

Actually this was much simpler than that. Check this out:

 

set(#x, $special folder("Program Files"), "Global")

 

 

Using this you should be able to concatenate the strings to get a correct path to Excel.

 

Sweet! That works great! Thanks for your help!

 

Ken

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...