Deploying a .cmd file with a reboot

8 views
Skip to first unread message

Heaton, Joseph@Wildlife

unread,
Dec 14, 2021, 6:16:51 PM12/14/21
to ntsyste...@googlegroups.com

To do this with SCCM, would you guys just add a restart command at the end of the .cmd, or would you call the .cmd from with a batch file and put the reboot in the batch file, or would you package it some other way?

 

Joe Heaton

Managed Services and Operational Support Unit

Information Technology Operations Branch

Data and Technology Division

CA Department of Fish and Wildlife

1700 9th Street, 3rd Floor

Sacramento, CA  95811

Desk:  916-919-5816

 

Michael B. Smith

unread,
Dec 14, 2021, 6:58:09 PM12/14/21
to ntsyste...@googlegroups.com

I’d add a restart (shutdown -r -f -t 0) at the end of the cmd.

--
You received this message because you are subscribed to the Google Groups "ntsystemcenter" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ntsystemcente...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ntsystemcenter/SJ0PR09MB66867D7C9B399BEB818658EEAA759%40SJ0PR09MB6686.namprd09.prod.outlook.com.

CESAR. A

unread,
Dec 14, 2021, 7:28:42 PM12/14/21
to ntsyste...@googlegroups.com
Any reboot outside from SCCM, is hated by SCCM. Use a legacy package, create a program and let that do the reboot for you. 
Or create an app and update the exit code to reboot on exit code you decide 

Add a line like this to your cmd script 
Exit /b12345

Cesar A

Heaton, Joseph@Wildlife

unread,
Dec 15, 2021, 11:04:49 AM12/15/21
to ntsyste...@googlegroups.com

Thanks Michael, that sounds like a good plan.

 

I also have a Powershell script I’m trying to deploy.  I went the “easy” route first, just by putting into the Software Library – Scripts area, then testing by telling a specific machine to run it.  Unfortunately, the script also didn’t have a restart mechanism in it.  I’m thinking of adding:

 

Start-sleep -Seconds 300

Restart-Computer

 

 

Does that seem appropriate?

 

From: ntsyste...@googlegroups.com <ntsyste...@googlegroups.com> On Behalf Of Michael B. Smith
Sent: Tuesday, December 14, 2021 3:58 PM
To: ntsyste...@googlegroups.com

Subject: [ntsystemcenter] RE: Deploying a .cmd file with a reboot

 

WARNING: This message is from an external source. Verify the sender and exercise caution when clicking links or opening attachments.

 

Hood, Jeff

unread,
Dec 15, 2021, 11:11:49 AM12/15/21
to ntsyste...@googlegroups.com
does setting the exit code in the script to reboot not work?

something like 3010, which should trigger a soft reboot?

From: ntsyste...@googlegroups.com <ntsyste...@googlegroups.com> on behalf of Heaton, Joseph@Wildlife <Joseph...@wildlife.ca.gov>
Sent: Wednesday, December 15, 2021 10:04 AM
To: ntsyste...@googlegroups.com <ntsyste...@googlegroups.com>
Subject: [SOCIAL NETWORK] [ntsystemcenter] RE: Deploying a .cmd file with a reboot
 
*** External email - Exercise caution ***

Helton, Matt

unread,
Dec 15, 2021, 11:24:47 AM12/15/21
to ntsyste...@googlegroups.com

The Restart-Computer command has a delay option. However, you don’t need to go to that extreme if you don’t want to. A simple shutdown -r -t 300 would do the same thing and has other options that might give you more information to the user, if a user will see it. That being said, there are some features of the Powershell Restart-Computer command that might help with your task, such as waiting to reboot until certain processes or particular services become available. The Restart-Computer help page has a lot of useful information and examples. I’ve used it quite a bit for restarting computers via script. However, I usually use Invoke-Command to run shutdown -r -t 0 on a machine.

https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.management/restart-computer?view=powershell-7.2&viewFallbackFrom=powershell-6

 

Thanks,

Matt Helton

Assistant System Administrator

Library Information Technology Services

Milner Library, Room 177

Illinois State University

Office: 309-438-2876

Help Desk: 309-438-8399

Help E-mail: librar...@ilstu.edu

 

From: ntsyste...@googlegroups.com <ntsyste...@googlegroups.com> On Behalf Of Hood, Jeff
Sent: Wednesday, December 15, 2021 10:12
To: ntsyste...@googlegroups.com
Subject: [ntsystemcenter] Re: Deploying a .cmd file with a reboot

 

[This message came from an external source. If suspicious, report to ab...@ilstu.edu]

Reply all
Reply to author
Forward
0 new messages