with & without wscript.exe, cscript.exe, cmd /c, cmd.exe /c, cmd.exe /c /k
referencing the path to the .vbs file with /, \, and \\
exec()
shell_exec()
When I run the script from the command line it works perfectly.
The .vbs file is in a path outside the wwwroot folder. I set the permissions on the .vbs file & the folder it's in to allow read & execute for the Internet Guest Account.
The web page seems to indicate the script is being executed but nothing happens. Process Explorer only shows the error: "[Error opening process]" but no other information.
What is it you're expecting the vbs script to do? Looking at this, there isn't a way to determine what the .vbs has done, so unless you're logging something than it'll be hard to determine what is happening. The COM is a pain since it's marshaled across directly, so you can't do things like error handling using PHP without implementing all the necessary logic.
Not sure what vbs has the capability of doing, but you should start by adding a logging feature. You should be able to flag the run command as well to change the windowed mode (the 0 is hidden), but I'm not 100% sure if it'll remain open. To me it look like it needs a '5' as the option, which MS indicates would do:
Quote:
Activates the window and displays it in its current size and position.
If it stays open and the vbs issues output, I'd expect it to show up in there.
__________________
As of PHP 5.5, the MySQL library has been officially deprecated. It is recommended to move to either MySQLi or PDO libraries for your mysql connectivity. See here for help choosing which interface you prefer: http://php.net/manual/en/mysqlinfo.api.choosing.php
I made some changes trying psexec, but it still isn't working. However, it runs perfectly from the command line. I think it's gotta be close and it may have something to do with quoting/escaping double quotation marks or /'s or \'s, but I don't know what it's looking for:
Yep, that's always a catcher. I don't see it here, but it doesn't mean it doesn't exist.
I see you printed the $cmd here, so that's a good start. Drag that up from the HTML source itself (not from the browser window), and paste that into the command line. If that's good, we can look at the next step.
Does it ever make it to the echo that indicates the end and the $out, or does it just hang there and timeout eventually?
__________________
As of PHP 5.5, the MySQL library has been officially deprecated. It is recommended to move to either MySQLi or PDO libraries for your mysql connectivity. See here for help choosing which interface you prefer: http://php.net/manual/en/mysqlinfo.api.choosing.php
Execute a ".bat" file and have that ".bat" file contain the command.
If need be, PHP can create the ".bat" file.
The advantage is that you can actually then LOOK at the ".bat" file to see if it contains what you expect it to contain *and* you can execute it by hand to make sure it works when you do so.
I have even done this when invoking ".vbs" from other ".vbs" code. Just so I can be sure that I'm issuing the command I think I'm issuing.
__________________
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.
Execute a ".bat" file and have that ".bat" file contain the command.
If need be, PHP can create the ".bat" file.
The advantage is that you can actually then LOOK at the ".bat" file to see if it contains what you expect it to contain *and* you can execute it by hand to make sure it works when you do so.
I have even done this when invoking ".vbs" from other ".vbs" code. Just so I can be sure that I'm issuing the command I think I'm issuing.
That is a great idea. I tried it and it creates the .bat file with no problems. I can run the .bat file from the command line and it works. However, the shell_exec(<filename.bat>) still won't work. I get this error:
CScript Error: Loading your settings failed. (Access is denied. )
That is a great idea. I tried it and it creates the .bat file with no problems. I can run the .bat file from the command line and it works. However, the shell_exec(<filename.bat>) still won't work. I get this error:
CScript Error: Loading your settings failed. (Access is denied. )
Sounds like an ownership issue.
One thing to test, is on the command line launch the PHP directly by executing php -f /path/to/your/php/script.php, and seeing what that does. That should use your user credentials to execute the php script which in turn should use the same credentials when launching the shell_exec.
Try that and let us know how it turns out.
I like the bat idea as well, simple and central.
__________________
As of PHP 5.5, the MySQL library has been officially deprecated. It is recommended to move to either MySQLi or PDO libraries for your mysql connectivity. See here for help choosing which interface you prefer: http://php.net/manual/en/mysqlinfo.api.choosing.php
Sounds like an ownership issue.
One thing to test, is on the command line launch the PHP directly by executing php -f /path/to/your/php/script.php, and seeing what that does. That should use your user credentials to execute the php script which in turn should use the same credentials when launching the shell_exec.
Try that and let us know how it turns out.
I like the bat idea as well, simple and central.
I put in a
PHP Code:
echo shell_exec('whoami');
and it says the script is running under:
nt authority/iusr
I did some research (http://forums.iis.net/t/1147103.aspx) on that and it appears that "nt authority/iusr" replaced the anonymous IIS user in win 2008. Also, the permissions for it aren't configured the same way as a normal user.
I don't know what to do next. Any help will be greatly appreciated!
Yep, kinda sounded like a privilege issue. I remember how much of a pain it was configuring the 2003 machines with IIS, and I haven't looked back since :P
Take a look at this one: http://www.iis-aid.com/articles/trou...unable_to_fork which indicates to modify the acl for the IIS user. I'm not sure if I like that approach, but I think it beats executing it as another user with more access.
__________________
As of PHP 5.5, the MySQL library has been officially deprecated. It is recommended to move to either MySQLi or PDO libraries for your mysql connectivity. See here for help choosing which interface you prefer: http://php.net/manual/en/mysqlinfo.api.choosing.php
Yep, kinda sounded like a privilege issue. I remember how much of a pain it was configuring the 2003 machines with IIS, and I haven't looked back since :P
Take a look at this one: http://www.iis-aid.com/articles/trou...unable_to_fork which indicates to modify the acl for the IIS user. I'm not sure if I like that approach, but I think it beats executing it as another user with more access.
I checked out that site & it was helpful. I tried using icacls to modify the permission on c:\windows\system32\cscript.exe but it kept saying permission was denied. I then copied cscript from \system32 to the same folder where the .vbs file is and I was then able to set the permissions on the copy of cscript to give (RX) access to it.
I also found several pages that said to create these registry keys:
and echo back the output, it just echos the command line inside the batch file but the command doesn't execute. I know this because the .vbs file the batch file is executing logs what it's doing and it doesn't log anything when exec() runs (and it logs everything when I manually run the batch file from the command line).
Why does it just echo back the contents of the batch file without executing it?