473,505 Members | 14,618 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Remote shutdown

34 New Member
Hi all,

I want to do a remote shutdown to PC that is in the same domain as mine. I managed to do a command prompt version and it works but now i need to add it in my application, so i tried converting it to PHP, but i cannot seem to get the result i want. Can anyone tell me what i am doing wrong..

In CMD:
c:\WINDOWS\Power\psshutdown.exe \\172.16.223.213 -u sadmin -p studadmin -f -k -t 1

In PHP:
[PHP]
if (isset($_POST['Rshutdown']) && ($_POST['Rshutdown'] == 'Shutdown'))
{
$ipaddress = (' \\\\' .$_POST['Ripadd']);
$username = (' -u ' .$_POST['Rname']);
$userpw = (' -p ' .$_POST['Rpw']);
$shutdownMins = (' -t ' .$_POST['Rmins']);
$all = (($ipaddress) .($username) .($userpw));
$remoteshutdown = ('c:\windows\power\psshutdown.exe' .($all) .' -f -r' .($shutdownMins));
echo "$remoteshutdown";
$a = shell_exec($remoteshutdown);
}
[/PHP]

Thanks in advance..
Aug 12 '08 #1
4 5040
dlite922
1,584 Recognized Expert Top Contributor
when you do that echo there, is the output correct?

if so, it may be some kind of weird permission problem I think.

shell_exec() should work.

something else you can do is capture the output, send it to a file for example: command > test.txt

sends the output of "command" to test.txt in your working directory.


Good luck,


Dan
Aug 12 '08 #2
mirainc
34 New Member
hi Dan,
Yes the echo output is correct but i cannot figure out why it does not execute in cmd.. any other way to execute the command in cmd? besides shell_exec() because its still not working.

Thanks
Aug 12 '08 #3
Atli
5,058 Recognized Expert Expert
Try simply echoing the output of the shell_exec function. See if that returns anything useful.

Another thing... is it possible that there is a space missing between "psshutdown.exe" and the following parameters?
Aug 12 '08 #4
mirainc
34 New Member
Try simply echoing the output of the shell_exec function. See if that returns anything useful.

Another thing... is it possible that there is a space missing between "psshutdown.exe" and the following parameters?

Ok. Actually when i echo "$remoteshutdown"; the output i get is:
c:\WINDOWS\Power\psshutdown.exe \\172.16.223.213 -u sadmin -p studadmin -f -r -t 60

so i actually copied n pasted tat echo line into cmd and it works. So now i donno why the shell_exec() won't execute the line.

When i echo the shell_exec() function i get nothing. but if i don input any values i get the options for psshutdown (like, the different commands that shutdown, restart etc..) but when i input the ipaddress, username, pw n time nothing happens.
Aug 12 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

1
7547
by: Tim Gosselin | last post by:
I am writing a tcp tunnel but cannot find a way of detecting when a socket shuts down its read end without writing to the socket. For testing the write end of the remote endpoint I just do a: if...
0
1782
by: Hansi | last post by:
How can i start a winforms application on remote workstation, no matter who or if there is somebody logged in? My problems: 1) I need to shutdown computers in the evening that have not been...
0
1484
by: Crouchie1998 | last post by:
Happy Christmas Everyone!! How do I return the names of all the workstations (not Windows 2003 servers) in the domain into a treeview (with checkboxes) & shutdown those machines that are...
4
2785
by: Chris Johnson | last post by:
Hey all, I have a small app I have developed that periodically pings a list of server and returns their status. Given my environment I have setup the program such that a server can be down 4...
0
1701
by: Christian Jacob | last post by:
Hi there, I've got a serious problem with getting a remote shutdown functionality working with VB.NET. I am using WMI to query the target PC and invoke the Win32Shutdown method like this: Dim...
2
13121
by: yvan | last post by:
Hi, Here is my client/server scenario: Step1: Client connects to server and sends data sucessfully (using Socket.Send()). Step2: Server gracefully exists (calls Socket.Shutdown() and...
3
26975
by: joja15 | last post by:
I am working on a Python script to perform as a remote computer manager. So far I have a WOL function working and I would like to add the ability to show if a machine is on or off (I figured I...
1
1239
by: abhilash6it | last post by:
How can i perform remote shutdown and remote search using VB.Net
4
2998
by: =?iso-8859-1?B?S2VyZW0gR/xtcvxrY/w=?= | last post by:
Hi, can someone please show me a working Example of how i can create a process on a remote system (does not need UI) with WMI using C#? Thanks in advance,... Regards
0
7367
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7018
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5613
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5028
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3187
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3176
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1528
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
754
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
407
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.