Index | Recent Threads | Unanswered Threads | Who's Active | Guidelines | Search |
![]() |
World Community Grid Forums
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
No member browsing this thread |
Thread Status: Active Total posts in this thread: 6
|
![]() |
Author |
|
wplachy
Senior Cruncher Joined: Sep 4, 2007 Post Count: 423 Status: Offline |
In response to a suggestion in this thread I wrote a vbscript program that can be used send a command to the BOINC client to report completed WUs and then display the Windows shutdown dialog with the option of selecting; Log off, Restart, Cancel, etc.
----------------------------------------Overview: The script will post an update Command to BOINC for each attached project and then run the windows Shutdown dialog to select the action you want to take. It does not close the BOINC client and will not shutdown, restart, etc, Windows unless you select the action. If anyone is interested in trying/using the script instructions for installation and the script code are included in this thread. If you would like a copy of the script in a text file email me: 3times7plus at gmail dot com and I'll send it to you. Language: VBScript (installed with Windows since XP) OS: Windows XP, Vista and/or 7 Tested under: WinXP Pro SP3 32 & 64, Vista Ultimate SP2 64, Win 7 Pro 32 & 64 Tested with BOINC versions 6.2.28 & 6.10.58 Please post any comments, questions and or problems to this thread. Bill P ------------- Installation: 1) Open a new Notepad document 2) Copy the Script (from the '**Script Start** to the '**Script End** lines in this thread 3) Paste the copied Script into the new Notepad document 4) In Notepad click File->Save As and save the file to a folder of your choice with a name of your choice and with the file type .vbs The default Save as Type will be Text Documents (*.txt) Select All Types (*.*) and add the .vbs extension ex. c:\MyStuff\BoincRptSD.vbs 5) Locate the BOINC program (not data) folder. The default directory is c:\Program Files\BOINC or c:\Program Files (x86)\BOINC An easy way to locate it is to search the C: drive for boinccmd.exe which will be in the program directory 6) Verify the installation by: A) Open a Command Prompt window (Start->Run->cmd.exe) B) In the Command Prompt window enter: Cscript //nologo "the_full_path_to_the_vbs_file_you_saved_in_step_4" /P:"BOINC_Pgm_Path" /V ex. Cscript //nologo "c:\MyStuff\BoincRptSD.vbs" /P:"c:\Program Files\BOINC" /V C) Press Enter You should see something like this displayed: Starting BoincRptSD.vbs 12/11/2010 12:12:22 PM Profiling BOINC Project(s) Found: 1 Project(s) Requesting http://www.worldcommunitygrid.org/ update Waiting for BOINC to report Results Sleeping for 11 seconds Ended BoincRptSD.vbs 12/11/2010 12:12:22 PM And then a Windows Shutdown dialog window will open. Click Cancel to close it. If there is an error message and Help lines displayed correct the error and try again. Once it successfully runs open the BOINC messages tab and verify a User Update was requested. A important point to remember is that if either folder or the vbs file name contains a space you have to put double quotes around it, as in the example above. After installation and verification you can add the script to your Start menu. 1) Create a new shortcut on your Desktop (right-click on the Desktop and select New->Shortcut 2) In the "Type the location of the item:" box enter the exact same thing you entered in the Command Prompt during verification without the /V. ex. Cscript //nologo "c:\MyStuff\BoincRptSD.vbs" /P:"c:\Program Files\BOINC" 3) Click Next, Name the sortcut and click Finish 4) Verify the shortcut is correct by double clicking the shortcut. An empty Command Prompt window will open. If there is anything in it the location data you entered is incorrect. If the Command Prompt is blank it will take about 12 seconds and then the Command Prompt will close and the Windows Shutdown dialog box will open. Select Cancel. 5) To add it to the standard Windows Start Menu: Right click the Desktop icon and select "Pin to Start Menu" To add it to the Classic Start Menu: Right click the Desctop Icon and click Properties then copy the Target data from the shortcut Close the shortcut Properties window Right click the Start button and click Properties In the Start Menu tab click the Classic Start menu Customize.. button Click the Add... button Paste the data you copied from the shortcut into the Location box and click next Select "Programs" from the Start Menu tree and click Next Give it a name and click Finish Click OK twice 6) After it has been added you can delete the shortcut from the Desktop '**Script Start** 'Author: Bill Plachy 'Version: 1.0.0 'Date: 12/11/2010 'Use: Cscript //Nologo xxx.vbs /P:["]Boinccmd_Pgm_Path["] [/V] [/H] ' /P: (Required) Is the full path to the boinccmd.exe directory/folder ' Use "" before and after if path contains spaces ' /V [Optional] Verbose (shows status messages) ' Default is Quiet (do not show status messages) ' /H [Optional] This display! Const coSleepTime = 11000 'Time for BOINC to Update (In Milli-Seconds) Const coGetMstrURLCmd = " --get_project_status | find /I """ 'Get Project Status Command Const coProjCmd = " --project " 'Project Action Command Const coUpdOp = " update" 'Update Operation Const coMstrURL = "master URL:" 'Master URL(s) Search and Filter Const coProjWd = " Project(s)" If Not DoParms(boVerbose, stBCPath) Then 'Argument Error Wscript.quit 'End Now Else 'Show Status if Requested call ShowStatus(boVerbose, "Starting " & Wscript.ScriptName & " " & _ FormatDateTime(Now(), VBShortDate) & " " & _ FormatDateTime(Now(), VBLongTime) & vbcrlf & _ "Profiling BOINC" & coProjWd) 'Display Status End If Set WshShell = CreateObject("WScript.Shell") 'Set WScript Shell inNbURLs = -1 'Init Master URL Count Set objExec = WshShell.Exec("%ComSpec% /C " & _ stBCPath & coGetMstrURLCmd & coMstrURL & """") 'Get Master URL List Do While Not objExec.StdOut.AtEndOfStream 'Read All StdOut Lines stSOLine = objExec.StdOut.ReadLine 'Get Line Value t = InStr(1, stSOLine, coMstrURL, vbTextCompare) 'Look for Master URL Target in Text if t > 0 then 'Found it inNbURLs = inNbURLs + 1 'Increment Nbr Found ReDim Preserve stURLList(inNbURLs) 'Reserve Additional Storage stURLList(inNbURLs) = _ Trim(Right(stSOLine, Len(stSOLine) - (Len(coMstrURL) + t))) 'Store for Update End If Loop call ShowStatus(boVerbose, "Found: " & _ inNbURLs + 1 & coProjWd) 'Show Number Projects Found if inNbURLs > -1 then 'Found Active Prjects For i = 0 To inNbURLs Step 1 'Request Project Update For All Projects call ShowStatus(boVerbose, "Requesting " & _ stURLList(i) & coUpdOp) 'Document Status WshShell.Exec (stBCPath & coProjCmd & _ stURLList(i) & coUpdOp) 'Issue Update Command Next 'Give BOINC Time to Complete If Wscript.Version > 5 Then 'WSH Version Supports Sleep call ShowStatus(boVerbose, "Waiting for BOINC to report Results" & vbcrlf & _ "Sleeping for " & coSleepTime / 1000 & " seconds") 'Document Sleep Wscript.Sleep coSleepTime 'Wait xx Seconds End If End If call ShowStatus(boVerbose, "Ended " & Wscript.ScriptName & " " & _ FormatDateTime(Now(), VBShortDate) & " " & _ FormatDateTime(Now(), VBLongTime)) 'Doc End Time Set objExec = Nothing 'Release WshShell.Exec Storage Set WshShell = Nothing 'Release WshShell Storage Set WshShell = CreateObject("Shell.Application") 'Init Shell Object WshShell.ShutdownWindows 'Start Shutdown Dialog Set WshShell = Nothing 'Release Shell Object Storage Function DoParms(boVerbose, stBCPath) Const coBCPgm = "boinccmd.exe" 'Boinccmd.exe File 'Initlize Parm Defaults Set objArgs = Wscript.Arguments 'Init Argument Object boVerbose = False 'Default is Quiet stWkPath = "" 'Clear boinccmd.exe Path Build stErrMsg = "" 'Clear Additional Error Message 'Validate Parms If objArgs.Unnamed.Count > 0 then 'Incorrect Parm Format DoParms = False 'Show Help and End stErrMsg = "Arguments are incorrect" 'Set Add'l Message elseIf objArgs.Named.Count = 0 Then 'No Parms Used DoParms = False 'Show Help and End Else 'Some Named Parms Passed DoParms = True 'Default is Don't Show Help For i = 0 To objArgs.Count - 1 Step 1 'Validate Each Parm t = InStr(1, objArgs.Item(i), ":", vbTextCompare) 'Find End of "Name" If t > 0 Then 'Name + Value stParmNme = Mid(objArgs.Item(i), 2, t - 2) 'Set Parm Name Compare Else 'Name Only stParmNme = Mid(objArgs.Item(i), 2, 1) 'Set Parm Name Compare End If '/*-------------------------*/ '/* Store Argument Value */ '/*-------------------------*/ Select Case UCase(Left(stParmNme, 1)) 'First Character of Name Case "H" 'Wants Help DoParms = False 'Show Help and End Case "P" 'Boinccmd.exe Path stParmVal = Right(objArgs.Item(i), _ Len(objArgs.Item(i)) - t) 'Isolate Path Value t = InStrRev(stParmVal, _ Left(coBCPgm, InStr(1, coBCPgm, ".", vbTextCompare) - 1), _ -1, vbTextCompare) 'See if Pgm Included if t = 0 then 'Not Included t = Len(stParmVal) 'End of Value else 'Included t = t - 1 'End of Path end if If Mid(stParmVal, t, 1) = "\" Then 'Has Backslash stWkPath = Left(stParmVal, t) 'Use as Supplied Else 'Needs Backslash stWkPath = Left(stParmVal, t) & "\" 'Append One End if Case "V" 'Verbose Display boVerbose = True 'Set True Case Else 'Unknown Parm stErrMsg = "Unknown Argument: " & objArgs.Item(i) 'Set Add'l Message DoParms = False 'Show Help and End End Select Next End If If DoParms Then 'Not Requesting Help or Error Found If Len(stWkPath) = 0 Then 'If BOINC Path Not Specified stErrMsg = "Path to " & coBCPgm & " missing" 'Set Add'l Message DoParms = False 'Show Help and End else 'Specified - Validate Set objFSO = CreateObject("Scripting.FileSystemObject") 'Init File System Object If Not objFSO.FolderExists(stWkPath) Then 'Folder Doesn't Exist stErrMsg = stWkPath & " Doesn't exist" 'Set Error Message DoParms = False 'Show Help and End elseif not objFSO.FileExists(stWkPath & coBCPgm) then 'File Doesn't Exist stErrMsg = coBCPgm & " not found in " & stWkPath 'Set Error Message DoParms = False 'Show Help and End End If Set objFSO = Nothing 'Release File System Object Storage stBCPath = stWkPath & coBCPgm 'Return Full Boinccmd.exe Path End If End If If Not DoParms Then 'Error or Help Requested Call ShowHelp(stErrMsg) 'Show Help End If End Function Sub ShowHelp(ErrMsg) Const coVersion = "BoincRpt V1.0.0" 'This Script Version If Len(ErrMsg) > 0 Then 'Error Message to Display Wscript.Echo vbcrlf & "Error: " & ErrMsg & vbcrlf 'Display Error TextText End If Wscript.Echo coVersion & vbcrlf & vbcrlf & _ "Use: Cscript //Nologo " & Wscript.ScriptName & _ " /P:[""]Boinccmd_Pgm_Path[""] [/V] [/H]" & vbcrlf & _ " /P: (Required) Is the full path to the boinccmd.exe directory/folder" & vbcrlf & _ " Use "" before and after if path contains spaces" & vbcrlf & vbcrlf & _ " /V [Optional] Verbose (shows status messages)" & vbcrlf & _ " Default is Quiet (do not show status messages)" & vbcrlf & vbcrlf & _ " /H [Optional] This display!" End Sub Sub ShowStatus(boVerbose, stStatMsg) if boVerbose then 'Displaying Status Messages Wscript.Echo stStatMsg 'Display Status Message End if End Sub '**Script End**
Bill P
----------------------------------------![]() [Edit 4 times, last edit by wplachy at Dec 12, 2010 7:11:42 AM] |
||
|
Sekerob
Ace Cruncher Joined: Jul 24, 2005 Post Count: 20043 Status: Offline |
Holy Cow, Bill, very well thought out piece, to include checking the client version and elegant you offer the choice what to do at the end (shutdown/sleep/hibernate).
----------------------------------------Me Myself and Io had roughed up a few rips from Google and generated an extremely simple script in old .bat, not entering into a loop to update all the projects attached to a client... a single line for WCG only, more to add if so desired, and a ping loop to localhost to give it time and then call the shutdown procedure for W7, which I think will work in XP too. With 30 seconds delay, the pop-up screen will tell that one's got less than 1 minutes to interrupt the procedure. Finally created a shortcut on the Startbar menu with the standard system exit icon and a second shortcut to run the "shutdown -a" for a cancellation. Would you consider adding a bit to print out the times since last checkpoint "boinccmd --get_tasks", as when running CEP2, that's a serious matter and then give chance to hit Ctrl-Break (Wish there were a timer in BOINC to pick a task and then instruct to exit when the next one is reached. There's something for end of task these days.) The boincshutdown.bat script: @echo off PS, 12 coders in a room gives 13 programs :D
WCG
Please help to make the Forums an enjoyable experience for All! |
||
|
wplachy
Senior Cruncher Joined: Sep 4, 2007 Post Count: 423 Status: Offline |
Thanks for the kind word:-)
----------------------------------------Would you consider adding a bit to print out the times since last checkpoint "boinccmd --get_tasks", as when running CEP2, that's a serious matter and then give chance to hit Ctrl-Break I have a version that is almost there. It posts update commands for only those projects that have Ready to Report WU's, so as not to cause unecessary work for the project servers. I was going to add the CEP2 checkpoint check but got tied up with a personal matter. I'll add that and post result here. PS, 12 coders in a room gives 13 programs :D ![]() ![]() Bill P
Bill P
![]() |
||
|
FAHE
Advanced Cruncher Australia Joined: Apr 27, 2007 Post Count: 122 Status: Offline Project Badges: ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
**Sek and Bill P
----------------------------------------I am in awe of you pair. I spent half an hour trying to follow the vbs instruction set but my brain gave out. I will just believe you both. From one of the little crunchers I would just like to record my appreciation of the effort you put in to the wcg community. Peter ![]() |
||
|
Sekerob
Ace Cruncher Joined: Jul 24, 2005 Post Count: 20043 Status: Offline |
Thanks from us 2, but it's all in common interest... more tasks rescued from next days wingman finger drum heard around the planet when they wake up to the first Result Status page PV Jail Inmates roll call.
----------------------------------------:D
WCG
Please help to make the Forums an enjoyable experience for All! |
||
|
wplachy
Senior Cruncher Joined: Sep 4, 2007 Post Count: 423 Status: Offline |
@FAHE Thank you for the note of appreciation! I'll try to make this version a little easier to follow.
----------------------------------------![]() @Sek, I finished the update. It allows the user to set a threshold for the maximum amount of processing time that would be lost for any WU and/or the total amount of processing time that will be lost for all WUs in all projects. If a WU maximum is specified a list of the WUs by project that exceed the threshold is shown with the option to continue with the "shutdown" or cancel it. If the threshold for the total time that will be lost for all WUs for all projects is exceeded the total lost processing time is shown with the option to continue or suppress the "shutdown". The only problem is that given the way the forum software treats leading blanks plus the size of the script (~700 lines) I’m hesitant to post it in this note as it's difficult to read/follow and a pain to copy. In the start of this thread I posted an email address to send a request for the source in a text file. If you send me a note @ that address I’ll return a copy of the source. If you don’t want to use your real email and you don’t have a "throw away" email box you can create one here @FAHE and any other BOINC contributor that would like the source the same applies. Bill P
Bill P
![]() |
||
|
|
![]() |