473,651 Members | 2,790 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Executing a reboot command from SQL

Here is the block of the sproc that I?ve created. All lines execute
fine except for the ?exec master..xp_cmds hell @reboottc?. In order to
make this work from the query analyzer I had to set the MSSQLSERVER
service to have the same credentials as the thin clients we are trying
to shut down, that means the service is running as an Administrator on
the sql server with the same u/p as administrator on thin clients.
declare @RoomNumber varchar(6) -- for testing

set @RoomNumber = '1144' -- for testing

DECLARE @RoomIP varchar(15), @RebootTC
varchar(120), @shutdownStart varchar(20), @shutdownEnd varchar(85)

-- @ShutDownStart and @ShutDownEnd will be used
with the @RoomIP to build the shutdown command sent to the thin
clients

SET @ShutDownStart = 'shutdown -r -f -m \\'

SET @ShutDownEnd = ' -t 5 -c "Mandatory
iConnect Reboot issued during guest check in/out process"'

SELECT @RoomIP = IP FROM Rooms WHERE
RoomNumber = cast(@RoomNumbe r AS INT)

SET @RebootTC = @ShutDownStart + @RoomIP +
@ShutDownEnd

-- print @RebootTC -- for testing

-- @RebootTC ends up looking like the line below based on the
@RoomNumber

-- shutdown -r -f -m \\172.18.16.103 -t 5 -c "Mandatory iConnect
Reboot issued during guest check in/out process?

-- Also the command below runs correctly when executed from SQL Query
Analyzer
EXEC master..xp_cmds hell @RebootTC
Jul 20 '05 #1
1 4255

"Steve Duke" <st*******@Comc ast.net> wrote in message
news:d3******** *************** ***@posting.goo gle.com...
Here is the block of the sproc that I?ve created. All lines execute
fine except for the ?exec master..xp_cmds hell @reboottc?. In order to
make this work from the query analyzer I had to set the MSSQLSERVER
service to have the same credentials as the thin clients we are trying
to shut down, that means the service is running as an Administrator on
the sql server with the same u/p as administrator on thin clients.


<snip>

I admit that I haven't looked at your code in detail, but all code executes
on the server, so any xp_cmdshell commands execute as the server, not the
client. That means that if you want a command to shut down servers or
workstations, then you'll have to give those permissions to the MSSQL or SQL
Server Agent proxy service account (see "xp_cmdshel l" in Books Online). You
might want to look at doing this outside MSSQL, unless you have a compelling
reason to do it in the database.

Simon
Jul 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
4519
by: Stephane Dalpe | last post by:
Hi all, I just want to know why when I'm installing jdk sometimes ask me to reboot and sometimes he don't. As part of our installation, we launch the jdk installation if it's not already installed, so it's important to know when the user will be asked to reboot. Thanks
0
1947
by: Nick Coghlan | last post by:
Anyone playing with the CPython interpreter's new command line switch might have noticed that it only works with top-level modules (i.e. scripts that are directly on sys.path). If the script is inside a package, the invocation will fail with a "Module not found" error. This PEP is aimed at fixing that :) Cheers, Nick.
15
2587
by: Nick Coghlan | last post by:
Python 2.4's -m command line switch only works for modules directly on sys.path. Trying to use it with modules inside packages will fail with a "Module not found" error. This PEP aims to fix that for Python 2.5. Previously, posting of a draft version of the PEP to python-dev and python-list didn't actually generate any responses. I'm not sure if that's an indication that people don't see the restriction to top-level modules as a problem...
1
2227
by: Steve Duke | last post by:
Here is the block of the sproc that I?ve created. All lines execute fine except for the ?exec master..xp_cmdshell @reboottc?. In order to make this work from the query analyzer I had to set the MSSQLSERVER service to have the same credentials as the thin clients we are trying to shut down, that means the service is running as an Administrator on the sql server with the same u/p as administrator on thin clients. declare @RoomNumber...
4
1430
by: martijn | last post by:
Hi, I am trying to create an application for our servicedesk. With this application the servicedesk members, can remotely image an workstation. What am looking for is a command line that reboots the users machine and creates a network share that starts up an batch file which calls Norton ghost with the right parameter to image the user machine.
4
1875
by: Urs Vogel | last post by:
Hi I deploy a Windows Service which requires a reboot after setup. The setup project, however, does not automatically recognize this requirement.How do I force a reboot (or set a reboot property) in the setup project (VS 2003)? Any hints are appreciated. Thanks, Urs
3
7146
by: lukecooley | last post by:
I am new to coding in vb.net and I am trying to add a registry value in the runonce key. The key is added correctly, as I can see it when going directly into the registry after executing my code, but when I reboot, the value (aka the .cmd file) is not executed and the string value is not deleted from the registry (at HKLM\Software\Microsoft\Windows\CurrentVersion\RunOnce). Here is the code I am using to create the key: Dim key As...
3
4008
by: iamsiju | last post by:
Hi, I am facing a problem with the Perl Telnet Object. My Telnet Object hangs just after issueing reboot command on the remote host. Please help me who faced this problem !!! Thanks in advance Siju Maliakkal
2
4690
by: =?Utf-8?B?VHJhY2tz?= | last post by:
When I run my setup of a vb.net app made in VS2005 and setup made with the setup wizard and then modified in the ide, The .net 2 setup runs and installs and then asks to reboot. If you answer ok then the reboot happens and when the system comes back it says it cant find the setup1.msi file (my setup) and so wont continue and install my app. So how do I make it find setup1.msi and continue the setup after reboot (to setup my app) or even...
1
8465
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8581
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
7298
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...
1
6158
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5612
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
4144
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
2701
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
1
1910
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1588
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.