473,657 Members | 2,524 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\Powe r\psshutdown.ex e \\172.16.223.21 3 -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\po wer\psshutdown. exe' .($all) .' -f -r' .($shutdownMins ));
echo "$remoteshutdow n";
$a = shell_exec($rem oteshutdown);
}
[/PHP]

Thanks in advance..
Aug 12 '08 #1
4 5063
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 "$remoteshutdow n"; the output i get is:
c:\WINDOWS\Powe r\psshutdown.ex e \\172.16.223.21 3 -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
7592
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 not sock.recv(buffsize) I cannot write to the socket and check if send returns 0 though, because that involves sending data out of the which may not have come in yet. When I try polling the socket with:
0
1797
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 shutdown by the (roaming) users, no matter if there is somebody logged in or not. If there is somebody logged in and sitting in front of the PC, he should get a dialogue and be able to refuse the
0
1493
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 checked? I also need to know their IP addresses & whether they are at the login screen or logged in. Plus, return whether the machine has shutdown... Most machines are Windows XP Pro, but some are 2000 too.
4
2803
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 minutes before I get an alert. My problem now is that is a server is rebooted, it will be back up before the 4 minute window and I will not be aware that it has rebooted. I am looking for a way (as an administrator, or not, if possible) to detect
0
1708
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 aoInParams() As Object = {8} For Each mngObj As ManagementObject In mngColl mngObj.Scope.Options.EnablePrivileges = True
2
13143
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 Socket.Close()). I see the server connection status go from ESTABLISHED to FIN_WAIT2, the client connection go from ESTABLISHED to WAIT_CLOSE. Step3: client.Send() succeeds and return the number of bytes sent (over the closed connection!)
3
27028
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 would do so by pinging the machine and seeing if I get a response). I would also like to add the ability to remotely shutdown a computer from the python script. Does anyone have a code snippet for pinging an IP, a code snippet for shutting down a...
1
1248
by: abhilash6it | last post by:
How can i perform remote shutdown and remote search using VB.Net
4
3005
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
8324
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8842
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8740
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8617
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7352
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5642
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4173
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2742
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 we have to send another system
2
1733
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.