Need VBScript to show message to currently logged on user
Hi... I'm not an expert in scripting, so I don't know how to solve my problem...
I've made a VBScript to upgrade/install an application, which requires a certain install order of 3 packages. It detects if there is a current version and uninstall if there is... It's working fine, but the problem is, that any Microsoft Office product is closed automatically when removing the old version and when installing the new version... There is nothing I can do about that, because the applications requires this, so therefore I want to inform the user, that is logged on the computer, that Office applications will be closed in order to upgrade this particular application...
I know how to make a messagebox in VBScripting, BUT since we want to deploy this upgrade through MS SCE2010 the script will be run as System Account, and therefore no messagebox to the user of the machine...
How can I make my VBScript show a message box to a user, when the script is running as the local system account?!
Cheers
Bo Urskov
I've made a VBScript to upgrade/install an application, which requires a certain install order of 3 packages. It detects if there is a current version and uninstall if there is... It's working fine, but the problem is, that any Microsoft Office product is closed automatically when removing the old version and when installing the new version... There is nothing I can do about that, because the applications requires this, so therefore I want to inform the user, that is logged on the computer, that Office applications will be closed in order to upgrade this particular application...
I know how to make a messagebox in VBScripting, BUT since we want to deploy this upgrade through MS SCE2010 the script will be run as System Account, and therefore no messagebox to the user of the machine...
How can I make my VBScript show a message box to a user, when the script is running as the local system account?!
Cheers
Bo Urskov
0 Comments
[ + ] Show comments
Answers (7)
Please log in to answer
Posted by:
sunny07
13 years ago
Posted by:
anonymous_9363
13 years ago
Posted by:
bourskov
13 years ago
Hi...
I have thought of that approch as well, but as mentioned, NET SEND is not an option, since it is Windows 7, and therefore no NET SEND support... There is however a service call MSG.EXE but the problem as I see it, is that I need to know the username of the current user... But that could be retrieved by VBScript, right?!
I have thought of that approch as well, but as mentioned, NET SEND is not an option, since it is Windows 7, and therefore no NET SEND support... There is however a service call MSG.EXE but the problem as I see it, is that I need to know the username of the current user... But that could be retrieved by VBScript, right?!
Posted by:
anonymous_9363
13 years ago
Posted by:
itolutions
13 years ago
Posted by:
bourskov
13 years ago
Hi...
I'm not sure about user interaction with SCE2010, but I'll follow up on that point...
Just to clarify... I don't need the user to interact with anything... I just want to present some kind of message to the user, that during this mandatory upgrade of this application, their Office applications will close automatically... This is to prevent our IT department to be overloaded with users who think there is something wrong...
Since this installscript will run locally on the clients, I don't need the system account to have network access, and I've tested with PsExec on my local computer to run the msg.exe tool, and it works...
So if there is no other solution, I think I just have to make my VBScript get the username for the current user, and send a msg.exe to localhost\%username%
Cheers
Bo Urskov
I'm not sure about user interaction with SCE2010, but I'll follow up on that point...
Just to clarify... I don't need the user to interact with anything... I just want to present some kind of message to the user, that during this mandatory upgrade of this application, their Office applications will close automatically... This is to prevent our IT department to be overloaded with users who think there is something wrong...
Since this installscript will run locally on the clients, I don't need the system account to have network access, and I've tested with PsExec on my local computer to run the msg.exe tool, and it works...
So if there is no other solution, I think I just have to make my VBScript get the username for the current user, and send a msg.exe to localhost\%username%
Cheers
Bo Urskov
Posted by:
bourskov
13 years ago
Sorted it out... :)
This is a part of the script I ended up with... It is working perfectly when deployed by SCE 2010 and the script is being run as NT AUTHORITY\SYSTEM
If there is a user logged on, the user will get a message, if not, the script just does it's job...
This is tested with Windows 7 Enterprise...
Cheers
Bo Urskov
strComputer = "."
strDomainPrefix = "DOMAINNAME\" 'Set this to your actual domainname, i.e. WINDOM -
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\cimv2")
Set colComputer = objWMIService.ExecQuery _
("Select * from Win32_ComputerSystem")
For Each objComputer in colComputer
Wscript.Echo "User Name = " & objComputer.UserName _
& VBNewLine & "Computer Name = " & objComputer.Name
If objComputer.Username <> "" Then ' There is a user logged on locally.
Username = Replace(objComputer.Username, strDomainPrefix, "") ' This will fail, if no user is logged on locally.
End If
WScript.Echo objComputer.UserName
WScript.Echo Username
WScript.Echo objComputer.Domain
Txt = "Text to current user goes here..."
Set WshShell = WScript.CreateObject("WScript.Shell")
Return = WshShell.Run("msg " & Username & " " & Txt, 1, true)
Next
This is a part of the script I ended up with... It is working perfectly when deployed by SCE 2010 and the script is being run as NT AUTHORITY\SYSTEM
If there is a user logged on, the user will get a message, if not, the script just does it's job...
This is tested with Windows 7 Enterprise...
Cheers
Bo Urskov
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
so that the conversation will remain readable.