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.
Related
So im currently trying to make a script that runs a specific website in application mode!
The only thing that i really want now, is for the website to also have another icon on the taskbar when launched.
Could i do this through VBS?
This is my current script:
Dim objShell
Set objShell = WScript.CreateObject( "WScript.Shell" )
objShell.Run("""C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"" --app=https://faceit.com")
objShell.Run("""C:\Program Files\FACEIT AC\faceitclient.exe""")
Set objShell = Nothing
I only want the chrome window that is launched to change icon. Not the "faceitclient.exe"
Icons on the taskbar are property of the running processes. You can't change them with .vbs script. Only changing of .exe file resources could do this and it's pretty hard with vbs (if possible at all).
I have shared a folder.
When I right-click it, it says under "Sharing":
"Network path: \DESKTOP-K77052H\Users\VMWareUser\Desktop\ausgaber"
(I have attached a screenshot).
However, this folder is not listed when I query Win32_Share:
Dim strComputer As String = "."
Dim objWMIService As Object = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Dim colShares As Object = objWMIService.ExecQuery("Select * from Win32_Share where type=0")
For Each objShare In colShares
Debug.Print(objShare.path)
I do see other shared folders, but not this one.
The other ones that our output in the above code do not have special permissions, just like the folder in question, so I don't understand the difference between those and the folder that I expect to the output in the above function.
I've also restarted the computer, deleted the share, shared it again, it wouldn't help.
What might be the issue here?
I found myself in similar situation when few folders were shared when I enable sharing via property dialog and few weren't.
To fix this you need to enable sharing by clicking on Advanced Sharing... button, see attached image below:
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.
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.
I searched the web and found a vb script to tile windows on the desktop. But I want to tile specific windows or apps. For example, if I open three images in Paint and one Excel file, I only want to show Paint apps tiling on the desktop.
I changed my code as suggested by Dai, however all windows are tiling.
There is another question. In my code I filtered "Untitled -Paint". However if I opened image, there would be "filename -Paint" . How can I get them?
Here is the code so far:
Option Explicit
Dim oWS, oShell
Set oShell = CreateObject("Shell.Application")
Set oWS=CreateObject("WScript.Shell")
Dim App
App="Untitled - Paint"
If oWS.AppActivate(App) then
else
WScript.Sleep 500
oWS.SendKeys "% x"
End if
oShell.TileVertically
WScript.Quit