mr-es335 Posted September 7, 2023 Share Posted September 7, 2023 Good day, I am porting all of my cmd/nircmd scripts to Autoit! and have the following that I could use some assistance with...as I have been unable to locate such information myself... @echo off :: ----------------------------------------------- wmic computersystem where caption="[existing computer name]" rename "[new computer name]" :: ----------------------------------------------- wmic computersystem where name="%computername%" call joindomainorworkgroup name="[new domain name]" :: ----------------------------------------------- wmic /namespace:\\root\default Path SystemRestore Call disable "C:\" :: ----------------------------------------------- nircmd exitwin reboot ; Shutdown(2) Thank you for any assistance one could provide. mr-es335 Sentinel Music Studios Link to comment Share on other sites More sharing options...
rsn Posted September 7, 2023 Share Posted September 7, 2023 (edited) When I have to use WMIC.exe, I usually do the following: $iPID = Run( @comspec & " /c %windir%\system32\wbem\wmic.exe [command arguments]" , "" , @SW_HIDE ) ProcessWaitClose ($iPID) There are other methods too using: ObjGet() But it takes a bit more effort. As for shutdown/reboot, have a look at the help file for: Shutdown ( ) Edited September 7, 2023 by rsn Link to comment Share on other sites More sharing options...
water Posted September 7, 2023 Share Posted September 7, 2023 Please have a look at Script-o-matic It creates WMI commands in pure AutoIt for you. rsn 1 My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
mr-es335 Posted September 8, 2023 Author Share Posted September 8, 2023 water, Can you please provide me with an example of how to use/update the following: wmic.exe computersystem where name="%computername%" call joindomainorworkgroup name="NOTTOOSURE" Thanks. mr-es335 Sentinel Music Studios Link to comment Share on other sites More sharing options...
water Posted September 8, 2023 Share Posted September 8, 2023 Nothing I have tried myself. But when you search the forum for "joindomainorworkgroup" you will find some scripts describing how to add a computer. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
Solution mr-es335 Posted September 8, 2023 Author Solution Share Posted September 8, 2023 rsn and water, Thank you both so very much for your assistance....very much appreciated! water: I will consider Script-o-matic at a later point...just need to port all of my nircmds to autoit! at the moment. Thanks however for the tip... nsr: Thank you for the sampling...I had to adjust the double-quotes to single-quotes...but other-than-that, all is working as it should! So again, "Thank you!" For interest...here is the updated script... #RequireAdmin ; ----------------------------------------------- ; Previous: wmic computersystem where caption="[existing computer name]" rename "[new computer name]" $iPID = Run( @comspec & " /c %windir%\system32\wbem\wmic.exe computersystem where caption='DESKTOP-7MLUNGI' rename 'RML_LABS_SYS'" , "" , @SW_HIDE) ProcessWaitClose ($iPID) ; ----------------------------------------------- ; Previous: wmic computersystem where name="%computername%" call joindomainorworkgroup name="[new domain name]" $iPID = Run( @comspec & " /c %windir%\system32\wbem\wmic.exe computersystem where name='%computername%' call joindomainorworkgroup name='BETHEL'" , "" , @SW_HIDE) ProcessWaitClose ($iPID) ; ----------------------------------------------- ; Previous: wmic /namespace:\\root\default Path SystemRestore Call disable "C:\" $iPID = Run( @comspec & " /c %windir%\system32\wbem\wmic.exe /namespace:\\root\default Path SystemRestore Call disable 'C:\'" , "" , @SW_HIDE) ProcessWaitClose ($iPID) Sleep(1000) ; ----------------------------------------------- ; Previous: nircmd exitwin reboot Shutdown(2) ; ----------------------------------------------- Thanks again...to you both!! mr-es335 Sentinel Music Studios Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now