nbtech Posted June 9, 2009 Share Posted June 9, 2009 (edited) Before you say it, I know there are other options out there but I have been given the task by my company, to make Remote Assistance work. The problem is, having all the systems work the same and the services that were already running or not running etc. I wrote this as one of my first scripts. Feel free to give pointers. What it does is queries our SMS server, then you take that information and type it in, then it disables their firewall, enables remote support, opens the remote assistance page and types in the system name. After closing help and support remote assistance, it then restores the firewall and remote support services to their previous state. I know it's sloppy but I'm new and inexperienced so any pointers are greatly appreciated. expandcollapse popup$firewallsvc = 1 $remoteassistancesvc = 1 ;Obtains report from SMS of user system. Does not automatically obtain info, in case more than one system appear $username = InputBox("Select User", "Logon name of user to access", "") ShellExecute("http://smsserver/SMSReporting_CM1/Report.asp?ReportID=12&variable=" & $username) Sleep(1000) WinActivate("Select User") ;Input of the system to connect to $system = InputBox("System Name", "Enter the name of the system to connect to", "") ;Firewall service checked and disabled RunWait(@ComSpec & " /c " & "sc \\" & $system & " query SharedAccess > temp.txt", "", @SW_HIDE) $line = FileReadLine("temp.txt", 4) $line2 = FileReadLine("temp.txt", 2) If $line2 <> "SERVICE_NAME: SharedAccess" Then MsgBox(0, "FAILED", "Connect Failed, Contact your administrator") Exit EndIf If $line = " STATE : 4 RUNNING " Then RunWait(@ComSpec & " /c " & "sc \\" & $system & " stop SharedAccess > temp.txt", "", @SW_HIDE) $firewallsvc = 10 RunWait(@ComSpec & " /c " & "sc \\" & $system & " query SharedAccess > temp.txt", "", @SW_HIDE) $line = FileReadLine("temp.txt", 4) If $line = " STATE : 1 STOPPED " Then MsgBox(0, "Firewall", "Windows Firewall and ICS has been disabled", 3) EndIf ElseIf $line = " STATE : 1 STOPPED " Then MsgBox(0, "Firewall", "Windows Firewall and ICS were already disabled", 3) EndIf ;Checking and starting Remote Assistance service RunWait(@ComSpec & " /c " & "sc \\" & $system & " query RDSessMgr > temp.txt", "", @SW_HIDE) $line = FileReadLine("temp.txt", 4) #MsgBox(0, "Remote Assistance", "RA is"&$line) If $line = " STATE : 1 STOPPED " Then RunWait(@ComSpec & " /c " & "sc \\" & $system & " start RDSessMgr > temp.txt", "", @SW_HIDE) $remoteassistancesvc = 10 RunWait(@ComSpec & " /c " & "sc \\" & $system & " query RDSessMgr > temp.txt", "", @SW_HIDE) $line = FileReadLine("temp.txt", 4) If $line = " STATE : 4 RUNNING " Then MsgBox(0, "Remote Assistance", "RA service has been started", 3) EndIf ElseIf $line = " STATE : 4 RUNNING " Then MsgBox(0, "Remote Assistance", "Remote Assistance was already running", 3) EndIf ;Opens Help and Support Remote Assistance ShellExecute("hcp://cn=microsoft%20corporation,l=redmond,s=washington,c=us/Remote%20Assistance/Escalation/Unsolicited/Unsolicitedrcui.htm") WinWaitActive("Help and Support Center") Sleep(1500) Send($system) WinWaitClose("Help and Support Center") ;ending remote assistance If $remoteassistancesvc = 10 Then RunWait(@ComSpec & " /c " & "sc \\" & $system & " stop RDSessMgr > temp.txt", "", @SW_HIDE) RunWait(@ComSpec & " /c " & "sc \\" & $system & " query RDSessMgr > temp.txt", "", @SW_HIDE) $line = FileReadLine("temp.txt", 4) If $line = " STATE : 3 STOP_PENDING " Then $waiting = 30 While $waiting = 30 MsgBox(0, "waiting", "Waiting", 1) Sleep(5000) RunWait(@ComSpec & " /c " & "sc \\" & $system & " query RDSessMgr > temp.txt", "", @SW_HIDE) $line = FileReadLine("temp.txt", 4) If $line = " STATE : 1 STOPPED " Then $waiting = 10 WEnd EndIf MsgBox(0, "Remote Assistance", "Remote Assistance Service on " & $system & " has been stopped") ElseIf $remoteassistancesvc = 1 Then MsgBox(0, "Remote Assistance", "Remote Assistance was not stopped on " & $system & " because it was already started") EndIf ;restarting firewall service If $firewallsvc = 10 Then RunWait(@ComSpec & " /c " & "sc \\" & $system & " start SharedAccess > temp.txt", "", @SW_HIDE) $line = FileReadLine("temp.txt", 4) If $line <> " STATE : 4 RUNNING " Then $waiting = 30 While $waiting = 30 MsgBox(0, "waiting", "Waiting", 1) Sleep(5000) RunWait(@ComSpec & " /c " & "sc \\" & $system & " query SharedAccess > temp.txt", "", @SW_HIDE) $line = FileReadLine("temp.txt", 4) If $line = " STATE : 1 STOPPED " Then $waiting = 10 WEnd EndIf MsgBox(0, "Firewall Service", "Firewall Service on " & $system & " has been restarted") ElseIf $firewallsvc = 1 Then MsgBox(0, "Firewall", "Windows Firewall and ICS was not restarted on " & $system & " because it was already stopped") EndIf FileDelete("temp.txt") Edited June 9, 2009 by nbtech Link to comment Share on other sites More sharing options...
nbtech Posted June 11, 2009 Author Share Posted June 11, 2009 Any comments even of yay or nay? Link to comment Share on other sites More sharing options...
sbailey5 Posted September 5, 2012 Share Posted September 5, 2012 This rocks for those of us in the I.T. field. I am going to take a look at this and see if I can alter it to work for my company. Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted September 5, 2012 Moderators Share Posted September 5, 2012 (edited) sbailey5, are you on SMS still or on SCCM (as this post is 3 years old)? There is an SCCM UDF in my signature that may be better for you. Edited September 5, 2012 by JLogan3o13 "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! Link to comment Share on other sites More sharing options...
sbailey5 Posted September 5, 2012 Share Posted September 5, 2012 OK, I look at the code and it looks like simply changing the sms server link will get the search script to function. however, the shell execute will only work for Windows XP. It won't work for Windows 7. Wish it did, I am looking for a script that will work in Windows 7 and will do it unsolicited without requesting control or user interaction at all. I can get AutoIt to ask for the computer name and run the msra.exe /offerra command on the computer name. However, I can't get the winactivates to work on the remote computer. $ComputerName = 'Remote ComputerName' Run(@ComSpec & ' /c msra.exe /offerra ' & $ComputerName, @TempDir, @SW_HIDE) WinWait("Windows Remote Assistance") WinActivate("Windows Remote Assistance") ControlClick("Windows Remote Assistance", "", "[CLASS:Button; TEXT:Yes; INSTANCE:1]") Link to comment Share on other sites More sharing options...
sbailey5 Posted September 5, 2012 Share Posted September 5, 2012 SCCM 2007. Link to comment Share on other sites More sharing options...
sbailey5 Posted September 5, 2012 Share Posted September 5, 2012 We are just starting to migrate to Windows 7 and I am trying to come up with a method to use Windows 7 built in remote assistance. Link to comment Share on other sites More sharing options...
sbailey5 Posted September 5, 2012 Share Posted September 5, 2012 Much thanks JLogan... Removing a single computer from a collection is another project we were working on. Goal being to enable the I.T. tech to remove a computer from a collection when replacing/reimaging. Helps keep the SCCM database clean. Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted September 5, 2012 Moderators Share Posted September 5, 2012 (edited) Definitely. Are you on 2007 or 2012?Edit: just saw your response further up. I am releasing the new version of the script here in a few days; it includes not only the software delivery and right click tools, but hardware imaging and User State Migration. Edited September 5, 2012 by JLogan3o13 "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! Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted September 5, 2012 Moderators Share Posted September 5, 2012 We are just starting to migrate to Windows 7 and I am trying to come up with a method to use Windows 7 built in remote assistance.Is there a reason you're not using the Remote Tools through SCCM? RA is doable in Win7 if you're remote controlling another Win7 box. Sucks in a mixed environment though. "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! 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