stan0ne Posted December 16, 2019 Posted December 16, 2019 (edited) Hi. do I convert a code? expandcollapse popupOption Explicit Title = "Bilgisayar Tanimlama" Dim Title,strComputer,objWMIService,strNewName,objComputer Dim Obj,Question,err,strDescription,colComputers,x If Not WScript.Arguments.Named.Exists("elevate") Then CreateObject("Shell.Application").ShellExecute DblQuote(WScript.FullName) _ , DblQuote(WScript.ScriptFullName) & " /elevate", "", "runas", 1 WScript.Quit End If Call Rename_PC() Call Ask4Reboot() Sub Rename_PC() strComputer = "." Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") strNewName = Inputbox ("Bilgisayar Adi Giriniz:",Title, ChrW(246) & "Ornek: BIMsavasb") If strNewName = "" Then Wscript.Quit() Set colComputers = objWMIService.ExecQuery ("Select * from Win32_ComputerSystem") For Each objComputer in colComputers err = objComputer.Rename(strNewName) Next End Sub Sub Changing_Descrption() strDescription = Inputbox("Enter Description : ",Title,"Machine blalllaaaaaaa") If strDescription = "" Then Wscript.Quit() Set Obj= GetObject("winmgmts:\\" & strComputer).InstancesOf("Win32_OperatingSystem") For Each x In Obj x.Description = strDescription x.Put_ Next End Sub Sub Ask4Reboot() Question = MsgBox("Bilgisayar Adi " DblQuote(strNewName) & " olarak degistirilecek." & vbCrLf &_ "Simdi yeniden baslatmak istiyor musunuz?",VbYesNo+VbQuestion,Title) If Question = VbYes then Reboot() Else LocalScript() End If End Sub Function DblQuote(Str) DblQuote = chr(34) & Str & chr(34) End function Sub Reboot() Dim ws,Command Set ws = CreateObject("Wscript.Shell") Command = "cmd /K @echo off & net use w: \\dc\PublicFiles\Scripts /user:savas.local\test passx /persistent:no & call w:\LanRename.vbs & net user administrator /active:yes & net user administrator passxx & net user bislem /delete & shutdown /r /t 5 /c "& DblQuote("Bilgisayar yeniden basliyor..") ws.run Command,1,True End Sub Sub LocalScript() Dim ws,Command Set ws = CreateObject("Wscript.Shell") Command = ("cmd /K @echo off & net use w: \\dc\PublicFiles\Scripts /user:savas.local\test passx /persistent:no & call w:\LanRename.vbs & net user administrator /active:yes & net user administrator passxx & net user bislem /delete & exit") ws.run Command,1,True End Sub I used VAConvert.04 but got an error. can you help me? THANKS Edited December 16, 2019 by stan0ne edit code
water Posted December 16, 2019 Posted December 16, 2019 Something like this (untested!): expandcollapse popup#RequireAdmin #include <MsgBoxConstants.au3> $sTitle = "Bilgisayar Tanimlama" Global $sTitle, $sComputer, $oWMIService, $sNewName, $oComputer Global $cObj, $oObj, $sQuestion, $sErr, $sDescription, $cComputers Rename_PC() Ask4Reboot() Func Rename_PC() $sComputer = "." $oWMIService = ObjGet("winmgmts:" & "{impersonationLevel=impersonate}!\\" & $sComputer & "\root\cimv2") $sNewName = InputBox("Bilgisayar Adi Giriniz:", $sTitle, ChrW(246) & "Ornek: BIMsavasb") If $sNewName = "" Then Exit $cComputers = $oWMIService.ExecQuery("Select * from Win32_ComputerSystem") For $oComputer In $cComputers $sErr = $oComputer.Rename($sNewName) Next EndFunc ;==>Rename_PC Func Changing_Description() $sDescription = InputBox("Enter Description : ", $sTitle, "Machine blalllaaaaaaa") If $sDescription = "" Then Exit $cObj = ObjGet("winmgmts:\\" & $sComputer).InstancesOf("Win32_OperatingSystem") For $oObj In $cObj $oObj.Description = $sDescription $oObj.Put_ Next EndFunc ;==>Changing_Description Func Ask4Reboot() $sQuestion = MsgBox($MB_YESNO + $MB_ICONQUESTION, $sTitle, 'Bilgisayar Adi "' & $sNewName & '" olarak degistirilecek.' & @CRLF & "Simdi yeniden baslatmak istiyor musunuz?") If $sQuestion = $IDYES Then Reboot() Else LocalScript() EndIf EndFunc ;==>Ask4Reboot Func Reboot() Local $sCommand $sCommand = "cmd /K @echo off & net use w: \\dc\PublicFiles\Scripts /user:savas.local\test passx /persistent:no & call w:\LanRename.vbs & net user administrator /active:yes & net user administrator passxx & net user bislem /delete & shutdown /r /t 5 /c " & '"Bilgisayar yeniden basliyor.."' RunWait($sCommand, "", @SW_SHOW) EndFunc ;==>Reboot Func LocalScript() Local $sCommand $sCommand = "cmd /K @echo off & net use w: \\dc\PublicFiles\Scripts /user:savas.local\test passx /persistent:no & call w:\LanRename.vbs & net user administrator /active:yes & net user administrator passxx & net user bislem /delete & exit" RunWait($sCommand, "", @SW_SHOW) EndFunc ;==>LocalScript 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
stan0ne Posted December 17, 2019 Author Posted December 17, 2019 20 hours ago, water said: Something like this (untested!): expandcollapse popup#RequireAdmin #include <MsgBoxConstants.au3> $sTitle = "Bilgisayar Tanimlama" Global $sTitle, $sComputer, $oWMIService, $sNewName, $oComputer Global $cObj, $oObj, $sQuestion, $sErr, $sDescription, $cComputers Rename_PC() Ask4Reboot() Func Rename_PC() $sComputer = "." $oWMIService = ObjGet("winmgmts:" & "{impersonationLevel=impersonate}!\\" & $sComputer & "\root\cimv2") $sNewName = InputBox("Bilgisayar Adi Giriniz:", $sTitle, ChrW(246) & "Ornek: BIMsavasb") If $sNewName = "" Then Exit $cComputers = $oWMIService.ExecQuery("Select * from Win32_ComputerSystem") For $oComputer In $cComputers $sErr = $oComputer.Rename($sNewName) Next EndFunc ;==>Rename_PC Func Changing_Description() $sDescription = InputBox("Enter Description : ", $sTitle, "Machine blalllaaaaaaa") If $sDescription = "" Then Exit $cObj = ObjGet("winmgmts:\\" & $sComputer).InstancesOf("Win32_OperatingSystem") For $oObj In $cObj $oObj.Description = $sDescription $oObj.Put_ Next EndFunc ;==>Changing_Description Func Ask4Reboot() $sQuestion = MsgBox($MB_YESNO + $MB_ICONQUESTION, $sTitle, 'Bilgisayar Adi "' & $sNewName & '" olarak degistirilecek.' & @CRLF & "Simdi yeniden baslatmak istiyor musunuz?") If $sQuestion = $IDYES Then Reboot() Else LocalScript() EndIf EndFunc ;==>Ask4Reboot Func Reboot() Local $sCommand $sCommand = "cmd /K @echo off & net use w: \\dc\PublicFiles\Scripts /user:savas.local\test passx /persistent:no & call w:\LanRename.vbs & net user administrator /active:yes & net user administrator passxx & net user bislem /delete & shutdown /r /t 5 /c " & '"Bilgisayar yeniden basliyor.."' RunWait($sCommand, "", @SW_SHOW) EndFunc ;==>Reboot Func LocalScript() Local $sCommand $sCommand = "cmd /K @echo off & net use w: \\dc\PublicFiles\Scripts /user:savas.local\test passx /persistent:no & call w:\LanRename.vbs & net user administrator /active:yes & net user administrator passxx & net user bislem /delete & exit" RunWait($sCommand, "", @SW_SHOW) EndFunc ;==>LocalScript that's incredible! great! It works! Much obliged. thank you so much..
stan0ne Posted December 17, 2019 Author Posted December 17, 2019 20 hours ago, water said: Something like this (untested!): ............. Can I ask you one more question? can we apply this code according to the operating system? for example, if the operating system is windows 10, all code should run, but if the operating system is windows 7, go to the "Ask4Reboot" SUB 'section. Is this possible? I'm sorry I didn't know how to do it.
stan0ne Posted December 17, 2019 Author Posted December 17, 2019 (edited) i solved; If @OSVersion = 'win_10' Then w10() EndIf If @OSVersion = 'win_7' Then w7() EndIf func w7() msgbox("","test","windows 7") EndFunc func w10() msgbox("","test","windows 10") EndFunc thanks Edited December 17, 2019 by stan0ne
Moderators JLogan3o13 Posted December 17, 2019 Moderators Posted December 17, 2019 Moved to the appropriate forum, as the AutoIt Example Scripts forum very clearly states: Quote Share your cool AutoIt scripts, UDFs and applications with others. Do not post general support questions here, instead use the AutoIt Help and Support forums. Moderation Team "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum!
stan0ne Posted December 17, 2019 Author Posted December 17, 2019 (edited) editt Edited December 17, 2019 by stan0ne
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