windows - Save & Close Open Excel 2007 Files Automatically BEFORE Shutdown Due To Power Loss -


i have spent days trying find way save users' open excel 2007 files before shutdown.exe or psshutdown.exe issued. i'm using windows 7 pro 64-bit machines w/uac enabled, including remote restrictions. don't want bypass these security measures.

i have developed vbscript can job, runs locally. code shown below:

option explicit '--------------------------------------------------  '*** dimension local variables *** dim objxl, msg, i, wshshell, strshutdownmessage, strmsg  '*** enable error handling *** on error resume next  '*** display server emergency , computer shutdown message *** set wshshell = wscript.createobject("wscript.shell") 'creates instance of windows scripting host shell (wshshell) '--- popup message - automatically closes after 15 seconds --- '--- (the "4112" ntype value sum of 16 - critical window type + 4096 - display on top!!) wshshell.popup "an unexpected server emergency has occurred." & chr(13) & chr(13) &_ "this computer automatically shut down 30 seconds when message disappears.  " &_ "please save data , close open applications immediately!", 15, "server emergency shutdown warning!",4112  '*** debugging exit *** 'wscript.quit  '*** wait 30 seconds before saving data, closing applications, , shutting down computer *** wscript.sleep 30000  '*** set excel object variable *** set objxl = getobject( , "excel.application")  '*** trap error , shutdown computer if no open excel workbooks *** if err.number > 0 'no open excel workbooks  'msgbox ("errorlevel ... = " & err.number)  'wscript.quit  wshshell.run("c:\windows\system32\shutdown.exe /f /s") 'run shutdown command end if  '*** save data , close each open excel workbook *** each in objxl.workbooks 'close each open excel workbook  i.save  i.close next  '*** shutdown computer *** wshshell.run("c:\windows\system32\shutdown.exe /f /s") 

the problem i'm having 429 error thrown when code executes following statement:

set objxl = getobject( , "excel.application") 

i have tried psexec, runas, vmrum (the remote machine vm), , task scheduler work around problem. figured out how determine session number of logged-in user on remote vm pass psexec run interactively remote vm user. shutdown warning message shows correctly on remote vm active user's desktop. 429 error - unless i'm logged on @ both local , remote computers remote vm's local administrator account (this workgroup, not domain, btw). thought might psexec problem, think it's either office 2007 or windows 7 uac permissions issue (thanks harry johnston in answer original post):

getobject() 429 error when using psexec run wscript file on virtual machine

is there way save open excel files on remote machine before shutdown issued? don't trust office autosave. clients' data important lose in power outage or due inability use autosave properly.

if shutdown normally, word et al pop dialogs. normal shutdown merely request programs close, program can cancel it. when forced programs terminated.

therefore normal shutdown of excel in clients. dialog. can cancel too. taskkill command line program can this.

taskkill /s computername /im excel.exe 

if refuse close can usethe /f flag force closing.


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -