i am new to the vb script. I have installed a program and have to call an License.exe and fill the License name and license key. Batch file to add it into the reg key is not working on this app. So it would be great if you can help me in this.When i open the License.exe with installed product . it asks me to fill License Name and the License Key. I dont know how to create to add that key through script but i was able to call the .exe. here is an example.
Dim objShell
Dim StrLicensename
Dim StrLicensekey
Set objShell = WScript.CreateObject( "WScript.Shell" )
objShell.Run("""C:\ProgramFiles\Resources\licensing.exe""")
StrLicensename = CStr("Melbourne Victoria")
StrLicensekey = Cstr("1234-4567835")
Set objShell = Nothing
Any help would be much appreciated.
Thank you in advance.
Well we need to package it and deploy through SCCM. Thats the reason our team was thinking to do ao rather than activating 50 machines manually.
Related
I try to run a vbs to open Outlook after i scanned a doc, it scans the document on Windows 10, but doesn't open Outlook, have you guys any idea?
BR Alex
Create the Outlook session.
Set objOutlook = CreateObject("Outlook.Application")
' Create the message.
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
Set objOutlookAttach = objOutlookMsg.Attachments.Add(output)
objOutlookMsg.Display
Reason was a missing permission on the folder where the scanned file was stored
I'm running into an interesting problem when I attempt to run VBScript code from within an HTA application. Specifically, when I query the Registry using WMI. Below is the VBscript (within .HTA file) code I am using to determing instance names of SQL server installations:
<script language="VBScript">
Sub searchRegistry
Const HKEY_LOCAL_MACHINE = &H80000002
strComputer = "."
Set oReg=GetObject( "winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv")
strKeyPath = "Software\Microsoft\Microsoft SQL Server\Instance Names\SQL"
oReg.EnumValues HKEY_LOCAL_MACHINE, strKeyPath, arrValueNames, arrValueTypes
msgbox "SQL Instances already installed: "
For i=0 To UBound(arrValueNames)
msgbox arrValueNames(i)
Next
End Sub
Null is returned and the loop throws a bound error. However, when I run this same code from an independent VBScript (.vbs) file it returns the proper values no problem. I assume this is a permissions issue but don't know where to start; don't know how to give windows HTA files permission to use WMI to search registry. Moreover, I am able to use WMI from HTA to do other things (get drive space, etc.) without issue so it must be registry restrictions? Any ideas?
As per this , Windows do allow HTA to update registry.
If it does not work for you, It could be related to your 'User Account Control' settings. Disable and try!
After days of toiling, I've figured it out...
On some 64-bit systems, HTA is incorrectly associated with the 32-bit MSHTA version (%windir%\SYSWOW64\mshta.exe) - resulting in only being able to access certain WMI classes.
In this case, add the path to the proper (64-bit) MSHTA to the command line. Example: "%windir%\system32\mshta.exe" "c:\whatever.hta" and the HTA should run with full access to WMI.
How can I get the installation folder path and put in a variable using VBScript?
My VBScript put files to certain folders and I want to do it dynamically.
The answer is that you can't because Visual Studio setups don't have that capability. All custom actions, vbscripts, C++, C# or whatever all run after the files have been installed. There is no capability to run code before or during that UI sequence. If you want to get the location from somewhere on the system, setup projects have a search that might work to get the default value.
I did an alternative to this problem. I used Shell.BrowseForFolder method to browse for a folder and returned its path:
function fnShellBrowseForFolderVB()
dim objShell
dim ssfWINDOWS
dim objFolder
ssfWINDOWS = 36
set objShell = CreateObject("shell.application")
set objFolder = objShell.BrowseForFolder(0, "Example", 0, ssfWINDOWS)
if (not objFolder is nothing) then
'Add code here.
end if
set objFolder = nothing
set objShell = nothing
end function
Source: http://msdn.microsoft.com/en-us/library/windows/desktop/bb774065(v=vs.85).aspx?cs-save-lang=1&cs-lang=vb#code-snippet-1
Hope this helps everyone.
Is there any way to launch default browser from intallshield after completing installation?
I followed installshield 2008 how to open url when install sucessfully completes. but did not understand how to do it.
Do we have any elegant way to do it?
Yes.
Here is what is needed to be done.
Write a batch file or vbscript that opens the url you want.
Convert that bat file into an exe using any of the converters available.
Call that exe via custom action.
Schedule that custom action after installation completes. i.e. After='InstallFinalize'.
You may also want to detect the default browser which you can do by googling the registry key.
The easiest way to do what you want would be to create the custom action as he said and go to the finish button and add action, choose your custom action and add the condition "NOT INSTALLED", so it only runs when it is installed and not for example while unisntalling.
Here is some sample code.
Dim iURL As String
Dim objShell
iURL = "www.happycat.com"
objShell = CreateObject("Shell.Application")
objShell.ShellExecute("C:\Program Files (x86)\Google\Chrome\Application\chrome.exe", iURL, "", "", 1)
Is there any way to make a .vbs file Read only,so that no one rather a specific person can read the content or change the content? But only can double click on that file to start its execution. I will set up a Main.vbs into which I would put the below
Dim oShell : Set oShell = WScript.CreateObject ("WScript.Shell")
oShell.run "A.VBS", 1, True
oShell.run "B.VBS", 1, True
oShell.run "C.VBS", 1, True
oShell.run "D.VBS", 1, True
The user will click only on the main.vbs to start the execution. All the .vbs I want to be Read/write protected. is my thought possible in practice?
Thanks,
If you can't read it you can't run it.
You can set permissions so that no other person (except administrators) can change the file, but you can't prevent people from being able to read the file if they're supposed to be able to run it.
Some other options to consider. The script can be encoded with the Microsoft Script Encoder. This will make it unreadable. One download link here (can't find the official Microsoft download link) http://www.softpedia.com/get/Programming/Packers-Crypters-Protectors/Microsoft-Script-Encoder.shtml. Of course, it is possible for people to decode the file using the appropriate tool.
Another option is to digitally sign the script with a code-signing certificate. This will still allow it to be viewed, but it will not be able to be modified without breaking the digital signature.
Or even encode the script then digitally sign it.
If the purpose of this is to protect your code, then you can always make an executable file.