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:
Related
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
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.
Does anybody know how to modify Windows XP appearance and color scheme using VBScript?
I have an application written in Visual C++ that needs Windows XP appearance (not classic) to be properly displayed and I want to set this properties from the Installation.
I use InstallShield to make the installer and VBScript to perform some custom actions. So it would be great if I can create a script in visual basic to change this properties.
This should do it:
rundll32 shell32.dll,Control_RunDLL desk.cpl desk,#themes /Action:OpenTheme /File:"%WinDir%\Resources\Themes\Luna.theme"
However you still need to get the user to click "OK" or use another utility to do this for you.
If you need to change individual appearance options (like window colors), you can modify the appropriate registry values under the HKEY_CURRENT_USER\Control Panel\Appearance and HKEY_CURRENT_USER\Control Panel\Colors keys. For example, this code will chamge the window background color to cream:
Set oShell = CreateObject("WScript.Shell")
oShell.RegWrite path & "HKCU\Control Panel\Colors\Window", "255 251 240", "REG_SZ"
Note, however, that Windows will probably apply the registry changes only after reboot.
If you need to load a ready .theme file, you can use the following code:
Const Theme = "C:\MyTheme.theme"
Set oShellApp = CreateObject("Shell.Application")
oShellApp.ControlPanelItem "desk.cpl desk,#Themes /Action:OpenTheme /file:""" & Theme & """"
Although, as sascha has pointed out, this will only bring up the Display Properties dialog with the specified theme selected; you still need the user to click OK or press Enter. It's possible to simulate key presses from script code using the WshShell.SendKeys method:
Set oShell = CreateObject("WScript.Shell")
' Wait until the Display Properties dialog is opened
While Not oShell.AppActivate("Display Properties")
WScript.Sleep 500
Wend
' Send the Enter key to close the dialog and apply the theme
Do
oShell.SendKeys "~"
WScript.Sleep 500
Loop While oShell.AppActivate "Display Properties"
But this approach is unreliable, because the user could click somewhere else so Enter would go to another window. Also, the Display Properties dialog caption is locale-dependent.
Another option would be to use the Theme.Manager API provided by the themeui.dll library starting from Windows XP SP1, but it doesn't seem to work on XP SP2. Anyway, you can find sample code here.
What I did was creating a c++ dll that I use as a Custom Action in Install Shield. In this dll I use the uxtheme.dll to set the luna.msstyle file as a theme. This is the function that does the work:
bool SetVisualStyle()
{
TCHAR szUxTheme[MAX_PATH+1];
UINT nSize = ::GetSystemDirectory( szUxTheme,
MAX_PATH);
szUxTheme[nSize] = '\0';
wcscat_s( szUxTheme,
MAX_PATH - nSize,
L"\\uxtheme.dll");
HMODULE hModule = ::LoadLibrary(szUxTheme);
if(!hModule)
{
return false;
}
typedef int (__stdcall *SETVISUALSTYLE) ( LPCWSTR szTheme,
LPCWSTR szScheme,
LPCWSTR szFontType,
int nReserved);
SETVISUALSTYLE pFnSetVisualStyle;
pFnSetVisualStyle = (SETVISUALSTYLE)GetProcAddress( hModule,
MAKEINTRESOURCEA(LOWORD(65)));
if(pFnSetVisualStyle)
{
pFnSetVisualStyle( L"C:\\WINDOWS\\Resources\\Themes\\Luna\\luna.msstyles",
L"NormalColor",
L"NormalSize",
1|32);
}
::FreeLibrary(hModule);
return true;
}
It's not perfect but it does what I need.
I hope that this can help someone else...if you have any doubt don't hesitate in asking me.
Cheers.
'Script name: yourtheme.vbs
'Object: Automate without command prompt the application of a Windows Theme by a VB script
'
'SCRIPT CONTENTS:
'Define Variables :
Set ShellApp = CreateObject("Shell.Application")
Set WsShell = CreateObject("Wscript.Shell")
'
'Define path for your file theme (put it on a network share and don't forget to apply "read and execute" ACL for your Users)
Theme = "typeyoursharepath\typeyourtheme.theme"
Theme = """" + Theme + """"
'Open Display Properties Windows, Select your theme and apply with keep focus on Windows
ShellApp.ControlPanelItem cstr("desk.cpl desk,#Themes /Action:OpenTheme /file:" & Theme)
Wscript.Sleep 100
WsShell.SendKeys "{ENTER}"
While WsShell.AppActivate ("Display Properties") = TRUE
WsShell.AppActivate "Display Properties"
Wend
'END OF SCRIPT
Applied successfully on Windows XP and Windows Server 2003R2 X86, and under Citix XenApp 4.6FP7 (OS: W2003R2X86 SP2) to apply Windows Embedded theme with blue background color more light.
Looks great on Citrix session user!
Integrated in user config GPO at user logon under Citrix XenApp.