Is it possible that someone here could explain how to use this code. Please keep in mind i am a complete amateur, so simplifications may be needed.
Private Const cPGM = "C:\VB Forum\startup\Example.exe"
Dim oShell As IWshShell_Class
Set oShell = New IWshShell_Class
oShell.RegWrite "HKLM\Software\Microsoft\Windows\CurrentVersion\Run\MyVBApp", _
cPGM, "REG_SZ"
How exactly is this code used? Is it saved as an .exe file and ran or what? Thanks for your prompt reply and informational feedback.
All this code does is add a value to the registry. It adds an item to the key
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run
with the name MyVBApp, and the value C:\VB Forum\startup\Example.exe
As it states in the article, this registry entry will cause the program C:\VB Forum\startup\Example.exe to launch automatically at system startup.
In order to use this code it does somehow have to be executed which, of course, requires an executable. If you want to see this code in action, the simplest thing to do would be to create a new "Standard EXE" project, add a reference to the Windows Script Host Object Model, paste the code into the Form_Load event, then run the app. Look at this registry key and you'll see this new entry. Be sure and delete it though because I assume you don't have some executable named C:\VB Forum\startup\Example.exe that you wish to run every time Windows starts, do you?
Related
I have a VB6 project that I didn't create but I have to update, when I go to make the exe I get a compile error: Method or data member not found, and it points too "SCom1.FileReceive" in the code below. When I look at the Main form, the SCom1 control is a PictureBox.
This code has been working for the last 5 years but I don't know why SCom1 is a picturebox, or why I'm getting the error, is it a reference? SCom1 to me looks like a MSComm function? Let me know if anyone has any ideas, I just don't know VB enough to know how to troubleshoot this. Thanks
If SCom1.FileReceive = True Then
WriteToLog (Now() & " FileReceive was true, now false")
SCom1.FileReceive = False
End If
The machine which you have opened the code doesn't have the mscomm32.ocx file or the ocx file not registered properly.
When vb cannot reference an ocx, it'll convert the relevant control to a picture box control.
What you have to do is, close the project without saving. Then open system32 folder and check for mscomm32.ocx file. If the file is not there then you have to download that from the intenet. The register the file using regsvr32 command in command prompt.
After this you can open the vb6 project and start working.
=========================================================
EDIT : Included the update in the comments to the answer, this will help other users in the future... :-)
if the method name doesn't look familiar to a known ocx file (in this case the SCom1.FileReceive), the missing component can be a custom ocx file.
So check on the working machine or in project folder whether there are any ocx file exists in the relevant name (in this case SCom.ocx).
if there is a file exists in such name, register that file using regsvr32 (if not registered), then add that to toolbox, then replace the picture box control with the relevant control (make sure the name tally).
Hopefully this question has a simple answer i'm overlooking! I have an IIS webserver with multiple sites on it. In Perfmon, they show up as w3wp#1, w3wp#2, etc... I'm writing a Logman script that will collect performance counter data using the counters/instances that I specify and I want to ONLY collect any w3wp worker processes.
I've tried a couple ways, but no luck:
\.NET CLR Memory(*w3wp*)\
\.NET CLR Memory(w3wp#*)\
\.NET CLR Memory(w3wp*)\
I've looked at the documentation here, and it seems like it claims to support wildcards, but not partial matches. I'm not sure what to make of that. Is there any way accomplish what I want? Hope I explained this well enough. Let me know if more details are needed.
Thanks!
There is a way to display the instance by appending Process Id to it. Since ProcessId do not change it helps determining the correct instance. This post describes the method - Perfmon: Identifying processes by PID instead of instance.
Relevant part from the link:
Making below registry change will display processes in the format of **ProcessName_PID** instead of **ProcessName#1**.
Click Start, click Run, type regedit, and then click OK.
Locate and then click the following registry subkey:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\PerfProc\Performance
On the Edit menu, click New, and then click DWORD Value.
Right-click New Value #1, click Rename, and then type ProcessNameFormat to name the new value.
Right-click ProcessNameFormat, and then click Modify.
In the Data value box, type one of the following values, and then click OK:
1: Disables PID data. This value is the default value.
2: Enables PID data.
Exit Registry Editor.
Warning: Serious problems might occur if you modify the registry incorrectly by using Registry Editor or by using another method. These problems might require that you reinstall the operating system. Microsoft cannot guarantee that these problems can be solved. Modify the registry at your own risk.
Important: If you enable this feature, you may be unable to monitor process-specific information by using third-party utilities or custom-made programs, and this functionality may change at any time in the future without notice.
Hope it helps someone.
I came up with a custom batch script that find the application pool ID, PID, and associates it with the IIS worker process in question. From there, I can manually FIND and REPLACE a generic placeholder in my perfmon configuration file to start collecting for the specific site(s). I can supply some details if there is interest.
The script work on the local computer but not remotely. Any idea?
I'm getting VBScript runtime error "ActiveX component can't create object: XStandard.MD5".
strSource = "C:\WINNT"
Set objFSO = CreateObject(Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder(strSource)
Set colfiles = objFolder.Files
For each file in colfiles
Set objMD5 = CreateObject("XStandard.MD5")
Go to the DLL folder and use in command prompt > regsrv32 XMD35.dll
http://www.xstandard.com/en/documentation/xmd5/
When you want to instruct a remote computer to instantiate a given ActiveX object, you need to specify the name of the remote server when calling the CreateObject(progID, [serverName]) function.
Otherwise, the script engine attempts to instantiate the object from the local machine.
For example:
Set objMD5 = CreateObject("XStandard.MD5", nameOfYourServer)
And of course, the component must be available on the server.
More info about CreateObject at MSDN
I don't know if it has anything to do with the syntax of line 2. you are missing an open quotation. You have:
Set objFSO = CreateObject(Scripting.FileSystemObject")
You should have:
Set objFSO = CreateObject("Scripting.FileSystemObject")
I realize this is an old question, but google sent me here with the same problem. In my case it was a 32-bit vs 64-bit issue - I needed to use the 32-bit version of CScript to execute.
More details here http://blogs.msdn.com/b/helloworld/archive/2007/12/12/activex-component-can-t-create-object-when-creating-a-32-com-object-in-a-64-bit-machine.aspx
The XStandard.MD5 is a component that is NOT standard in all computers. it is something that needs to be installed. However even after installing you may still run into the same error. This may be because you are running the script in a 64bit system. for some reason the 64bit wscript won't use the xmd5.dll. however you can make a workaround by associating the scriptfiles to run on the 32bit version of wscript. by
going into your default programs. (Windows 8+ Right click the startbutton area [category view] Click Programs, then Default Programs then Associate a file type or protocol with a program) (Windows 7- click on start then click default programs)
Then click vbs then click change program, change it to
C:\Windows\SysWow64\Wscript.exe
NOTE ONLY ON 64BIT
As dmogle says in his comment, you need to make sure that the component is installed on the remote computer. Assuming that you've got access to that computer, download the dll to it and then run the command regsvr32 XMD5.dll as can be seen here.
On another note, your script looks a little funny, the twp last lines are:
For each file in colfiles
Set objMD5 = CreateObject("XStandard.MD5")
Which means that you'll be creating an instance of the MD5 object for each file. I've never used the component in question, but I'm fairly sure that you probably want to create only one instance of the object and then call the functions on that object multiple times. So I'd suggest changing the order of those lines to:
Set objMD5 = CreateObject("XStandard.MD5")
For each file in colfiles
I am uninstalling some application and reading the software installation enumeration value from registry.
The problem is after uninstallation it is not changing the registry value untill unless the screen or regedit is not refreshed. after refreshing only i am getting the correct value.
Could some one help me out to refresh the regedit in python codes.
Regards,
upendra
I assume that by "refreshing" the "screen," you mean restarting the computer? Regardless, you can be sure that whatever registry keys you've modified will be correctly updated after the system is restarted. The registry is updated with lazy flush and writer threads, so my guess is that the changes you're making aren't flushed back to the registry immediately, but your question doesn't provide enough information about how you're modifying these registry values for me to be able to propose an alternative solution.
Perhaps more importantly, what are you trying to do here? Are you trying to get your uninstaller to verify that your application has been uninstalled? Why is this necessary? I feel like there has to be a better way than expecting registry edits to be committed and then read back out immediately.
I have kind the same problem. I "install" a python tool and environment and create some system variables in the registry. To refresh the registry I do the following:
def RefreshEnv():
HWND_BROADCAST = 0xFFFF
WM_SETTINGCHANGE = 0x1A
SMTO_ABORTIFHUNG = 0x0002
result = ctypes.c_long()
SendMessageTimeoutW = ctypes.windll.user32.SendMessageTimeoutW
SendMessageTimeoutW(HWND_BROADCAST, WM_SETTINGCHANGE, 0, u'Environment',
SMTO_ABORTIFHUNG, 5000, ctypes.byref(result))
This method is not refreshing the registry like I expected. I still have to open the window to edit the system variables in Windows and just click OK to refresh them. Otherwise my installed tools are crashing with an KeyError while trying to catch the environment variables.
I don't know if the Refresh function abovee will help you (I guess not), but at least it's a try.
You can use either of:
Just restart windows explorer with SysInternal's Process Explorer, or
If you have chocolatey installed, you can just type refreshenv in a PowerShell.
I am modifying the registry key and want to read that values without restarting the system.
I am able to read manually if I refresh the screen (F5 Button), but could you let me know how to capture this through python.
Here is my scenario. I am using Quicktest Pro (VB) to create an ActiveX object from a Labview VI that I built into an executable. In the build specs of the VI I have enabled ActiveX server option (ActiveX server name: "MyLabviewProgram") and in the VI Tools>Options>VI Server: Configuration the ActiveX box is checked.
So in QTP my code is:
Set IvApp = CreateObject("MyLabviewProgram.Application")
Set Vi = IvApp.getVIReference("MyLabviewVI.vi")
Vi.Call ParamNames, ParamVals
Upon running this I get a Run Error on the first line:
ActiveX component can't create object: 'MyLabviewProgram.Application'
I am having trouble figuring out why it errors. From National Instruments website they have a step in on one of their community pages about "LabVIEW Executable Used as ActiveX Server". The step is after building the EXE, 5. Run the EXE at least once on the target to activate the .TLB file. I've run the executable but not sure what they mean by on the target.
Does anyone have a suggestion on what I need to do to get this working?
Your description sounds like you correctly created a vi .exe. "On the Target" probably means "On the Target PC". The EXE adds all COM registration entries to the Windows registry each time it is executed.
It sounds like you haven't verified the COM registration entries are present in the registry yet. That's the first debugging step.
Run regedit.exe and search for MyLabviewProgram.Application under the HKEY_CLASSES_ROOT sub-key. You should find an entry that contains a sub-key that contains a value that contains a GUID (a large hexadecimal number).
That "class ID" GUID should be referenced under the HKCR/CLSID key. That reference should contain a LocalServer32 sub-key with the default value pointing to your application's .EXE filepath with the /Automation argument appended.
It seems likely that one of these steps will fail. I can't say exactly which one without more information.