|
Something like this:
CString sOS;
OSVERSIONINFO OSversion = {0};
OSversion.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
::GetVersionEx(&OSversion);
switch (OSversion.dwPlatformId) {
case VER_PLATFORM_WIN32s:
sOS.Format(_T("Windows %d.%d"),OSversion.dwMajorVersion,OSversion.dwMinorVersion);
break;
case VER_PLATFORM_WIN32_WINDOWS:
if (OSversion.dwMinorVersion == 0) {
sOS=_T("Windows 95");
} else {
if (OSversion.dwMinorVersion == 10) {
sOS=_T("Windows 98");
} else {
if (OSversion.dwMinorVersion == 90) {
sOS=_T("Windows ME");
}
}
}
break;
case VER_PLATFORM_WIN32_NT:
if (OSversion.dwMajorVersion == 5 && OSversion.dwMinorVersion == 0) {
sOS.Format(_T("Windows 2000 with %s"),OSversion.szCSDVersion);
} else {
if (OSversion.dwMajorVersion == 5 && OSversion.dwMinorVersion == 1) {
sOS.Format(_T("Windows XP %s"),OSversion.szCSDVersion);
} else {
if (OSversion.dwMajorVersion <= 4) {
sOS.Format(_T("Windows NT %d.%d with %s"),OSversion.dwMajorVersion, OSversion.dwMinorVersion,OSversion.szCSDVersion);
} else {
sOS.Format(_T(Windows NT Unknown %d.%d with %s)),OSversion.dwMajorVersion, OSversion.dwMinorVersion);
}
}
}
I prefer to wear gloves when using it, but that's merely a matter of personal hygiene
[Roger Wright on VB]
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
[Rich Cook]
|
|
|
|
|
The following code in theory should pop up a CMD window and show me the contents of a mapped drive mapped locally on a remote machine called "remote_workstation_a".
I'm running this script from my workstation and when I do the CMD window pop's up and tells me access denied. I tried logging in on the local machine as the domain administrator then run this script again with no luck.
I can't seem to figure out programmatically how to connect to a remote machine with a specific username and password yet still access the Win32_Process WMI object.
<br />
strComputer = "remote_workstation_a"<br />
Set objWMIService = GetObject("winmgmts:" _<br />
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2:Win32_Process")<br />
<br />
Error = objWMIService.Create("cmd.exe /K dir w:\", null, null, intProcessID)<br />
If Error = 0 Then<br />
Wscript.Echo "was started with a process ID of " _<br />
& intProcessID & "."<br />
Else<br />
Wscript.Echo " could not be started due to error " & _<br />
Error & "."<br />
End If<br />
I know this is possible because there are tools that already exist (psexec and beyondexec naming two) that can do this.
As an example with PSEXEC (from sysinternals.com):
<br />
psexec \\remote_workstation_a -u MY_PDC_DOMAIN\Adminstrator -p PASSWORD -i cmd.exe /K dir w:\<br />
This works so I know for certain this is possible I can't can't find anything clear in the WMI docs on MSDN to show me how to do this. Based on this I just need to encode the username and password of the account I would like to impersonate on the remote machine somehow (through the 'GetObject("winmgmts:" ...' call?).
The obvious answer is to just use PSEXEC but I need to run this a whole lot of times (which would open up MANY MANY processes) and PSEXEC's source is not exactly available.
Any hints or suggestions would be greatly appriciated.
The whole point of me attempting this is to make the tech guy's life a bit easier when pushing updates to the compute farm.
And while I'm at it why is all the WMI documentation so vague on almost everything? I'm eventually going to need to map a printer to each machine on the network and I'd love to do it though WMI but it's going to be a BIG BIG chore without some insight.
Thanks,
Sean
|
|
|
|
|
How about this:
Set objLocator = CreateObject("WbemScripting.SWbemLocator")
Set objWMIService = objLocator.ConnectServer(strComputer, "root\cimv2", Uname, Pwd)
Regards,
Venet.
Donec eris felix, multos numerabis amicos.
|
|
|
|
|
How many Handle can be create or open in Windows system? Same as how many file or socket can be open in Windows system? Thanks.
|
|
|
|
|
From MSDN:
Windows 95/98/Me: The system can support a maximum of 16,364 window handles.
No mention of the upper limit on NT, although if I had to guess I'd guess 1 billion (or is that 1 gigahandles? )
--Mike--
"So where does that leave us? Well, it leaves us right back where we started, only more confused than before." -- Matt Gullett
Ericahist | Homepage | RightClick-Encrypt | 1ClickPicGrabber
|
|
|
|
|
Thanks. Please tell me which section show this message in MSDN.
|
|
|
|
|
It's all over the place. CreateWindow() for one
--Mike--
"I'm working really, really fast at the moment, so a 3 minute outage becomes, due to time dilation, a 5 minute outage."
-- Chris Manuder, relativistic system administrator
Ericahist | Homepage | RightClick-Encrypt | 1ClickPicGrabber
|
|
|
|
|
i think 4,294,967,296(32 bit)...
would make sense
Don't try it, just do it!
|
|
|
|
|
Where can I find info on the usage of Environment Variables?
What I want to do:
1) use my own environment vars in links and shortcuts (e.g. Target and Start In fields in a shortcut's property dialog
2) use my own environment vars in batch files
3) set my own environment vars programmatically (from VC++)
If you have the answer, I wouldn't mind getting quick input on these specific issues too.
What I did:
I) under "My Computer | Properties | Advanced | Environment Variables", I created a user variable My_ROOT with C:\src_latest as the value.
II) Restarted my computer
III) at the DOS prompt, I tried to do simple things like cd My_ROOT, cd $My_ROOT, and in a shortcut I want altered, I tried to use My_ROOT\bin\CoolProg.exe (Target field).
No success to any of III) above.
Thanks a bunch!
Johnny
|
|
|
|
|
john john mackey wrote:
III) at the DOS prompt, I tried to do simple things like cd My_ROOT, cd $My_ROOT, and in a shortcut I want altered, I tried to use My_ROOT\bin\CoolProg.exe (Target field).
Use % instead of $
Try cd %My_ROOT%
[EDIT]
I just tried cd %TEMP%
[/EDIT]
John
|
|
|
|
|
Hi,
> 1) use my own environment vars in links and shortcuts
> (e.g. Target and Start In fields in a shortcut's property dialog
Surround the variable name with percent symbols; e.g.
%PROJECTS%\SomeTool.exe %LAUNCH_ARGS%
Also, if the variable represents a path and it may have a space in it I'd recommend changing the above to:
"%PROJECTS%\SomeTool.exe" %LAUNCH_ARGS%
> 2) use my own environment vars in batch files
Same again.
> 3) set my own environment vars programmatically (from VC++)
You can use the SetEnvironmentVariable API but this function only sets the variable for the current process (and any child processes that you may launch that inherit the current environment).
To set persistent environment variables you have to save them in the registry on NT/2K/XP and in AUTOEXEC.BAT on 95/98/Me. The rest of these notes are for NT/2K/XP only.
There are three types of environment variables: user, system and volatile.
The system variables are loaded first and are the same for every user on the system. They are stored as values of this registry key:
[HKLM\System\CurrentControlSet\Control\Session Manager\Environment]
If the value is a straight string the registry value type is REG_SZ, but if the value contains another environment variable name (in percent symbols) the value type is REG_EXPAND_SZ.
Next come the user environment variables. These are per user (duh!) and are stored in each user's registry hive under:
[HKCU\Environment]
These follow the same rules as the system variables; they can also refer to a system variable name (in percent symbols).
The final category is volatile variables; these are also per-user but are not saved between logon sessions; the system stores things such as the current logon server and domain name here. They are stored in:
[HKCU\Volatile Environment]
All three types are joined to create the final environment block your process is started with.
BTW, if you do create a tool to modify the environment and you want a running process (such as Explorer) to pick up the changes, you have to broadcast a WM_SETTINGSCHANGE message to notify them. A snippet of C++ does this:
const DWORD dwTimeout= 3000;
DWORD dwResult= 0;
SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE,
0, (LPARAM)_T("Environment"), SMTO_NORMAL,
dwTimeout, &dwResult);
Hope this helps.
Regards,
John Bates.
|
|
|
|
|
Thanks all. I got my shortcuts running with %My_ROOT%.
I now must fix my CoolProg.exe code so that when I supply a configuration file as an argument, and that configuration file itself uses the My_ROOT variable within, the environment variable is correctly interpreted as the full path (value).
Johnny
|
|
|
|
|
|
Thanks, I didn't know about the ExpandEnvironmentStrings() and therefore wrote my own string parser/environment variable expander (using the GetEnv() function and a while loop)
I think I will use the canned ExpandEnvironmentStrings() function.
HOWEVER, I am noticing a problem with the CWinApp::ParseCommandLine()
Maybe it's just me, but when I do the following
%My_ROOT%\bin\myapp.exe %My_ROOT%\config\myconfigs.prj
The argument "myconfigs.prj" doesn't get its pathname resolved -- it passes down to the lower underlyings of CWinApp::ParseCommandLine() as the literal string %My_ROOT%\config\myconfigs.prj and tries to open that file, which fails.
Any more guidance??
Thanks - Happy Independence Day!
Johnny
|
|
|
|
|
Try something like this (inside your InitInstance() function):
CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo);
_TCHAR szExpanded[MAX_PATH+1] = {0};
ExpandEnvironmentStrings(cmdInfo.m_strFileName, szExpanded, MAX_PATH);
Then, instead of cmdInfo.m_strFileName , use szExpanded ;
I prefer to wear gloves when using it, but that's merely a matter of personal hygiene
[Roger Wright on VB]
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
[Rich Cook]
|
|
|
|
|
How to Insert/Delete/Modify an entry in a Windows 2000 DNS Server with visual C++. Is there some API's for that purpouse. I've found some VBS's form Microsoft, but i haven't any clue how to convert in to VC++
Tkanks
|
|
|
|
|
You think MS could have provided a way to setup ASP.NET after your installed the .NET framework. I came back to my ASP.NET works after a break and IIS would not work at all, just blank error boxes. So I reinstalled IIS. Now I have to figure out how to install the .NET associations for IIS
Matt Newman
"Two things have come out of Berkley, Unix and Acid, we do not belive this to be a coincidence" Linux sucks twice as fast and 10 times more reliably, and since you have the source, it's your fault. -Ca1v1n
Post best viewed with lynx
|
|
|
|
|
Try aspnet_regiis.exe
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
|
|
|
|
|
Richard Deeming wrote:
Try aspnet_regiis.exe
I just found that. You would think that they would put this somewhere on the installing ASP.NET on IIS 5 page, but that would make sense and why would they do that.
Thanks for the response though
Matt Newman
"Two things have come out of Berkley, Unix and Acid, we do not belive this to be a coincidence" Linux sucks twice as fast and 10 times more reliably, and since you have the source, it's your fault. -Ca1v1n
Post best viewed with lynx
|
|
|
|
|
Hello,
Is it possible that I can have a process running on Windows XP Home that does not appear in the Windows Task Manager?
If so, how can I detect such processes?
Thanks,
-Me!
|
|
|
|
|
Anonymous wrote:
Is it possible that I can have a process running on Windows XP Home that does not appear in the Windows Task Manager?
Not AFAIK. That used to be a feature of pre-stone age Win9x OS
Regards,
Venet.
Donec eris felix, multos numerabis amicos.
|
|
|
|
|
Yes, it is possible but I hope Mircrosoft will fix it soon! I know of no way of detecting it but if it is a problem to you then contact me and we will find some solution.
jhaga
CodeProject House, Paul Watson wrote:
...and the roar of John Simmons own personal Nascar in the garage. Meg flitting about taking photos.Chris having an heated arguement with Colin Davies and .S.Rod. over egian values. Nish manically typing *censur*. Duncan racing around after his pet *c.* Michael Martin and Bryce loudly yelling *c.* C.G. having a fit as Roger Wright loads up *c.* . Anna waving her *c.* and Deb scoffing chocolates in the corner.
...Good heavens!
|
|
|
|
|
jhaga wrote:
Yes, it is possible but I hope Mircrosoft will fix it soon! I know of no way of detecting it but if it is a problem to you then contact me and we will find some solution.
Mind sharing it please?
Regards,
Venet.
Donec eris felix, multos numerabis amicos.
|
|
|
|
|
If you use VB:
To hide the program from the Taskmanager write the below code in the form load.
App.Taskvisible = False
[Edit: ok, you will see it in Processes but by selecting a strange name for it, it will be difficult to find]
http://www.codeproject.com/useritems/PreventClose.asp[^]
jhaga
CodeProject House, Paul Watson wrote:
...and the roar of John Simmons own personal Nascar in the garage. Meg flitting about taking photos.Chris having an heated arguement with Colin Davies and .S.Rod. over egian values. Nish manically typing *censur*. Duncan racing around after his pet *c.* Michael Martin and Bryce loudly yelling *c.* C.G. having a fit as Roger Wright loads up *c.* . Anna waving her *c.* and Deb scoffing chocolates in the corner.
...Good heavens!
|
|
|
|
|
jhaga wrote:
[Edit: ok, you will see it in Processes but by selecting a strange name for it, it will be difficult to find]
http://www.codeproject.com/useritems/PreventClose.asp[^]
I'm gonna check this article tomorrow, but if it works it changes many things.
Thanks
<edit>
It does work, no trace of the process in Task Manager, however it is still shown in the Process Explorer (sysinternals)
Thanks for the link.
</edit>
Regards,
Venet.
Donec eris felix, multos numerabis amicos.
|
|
|
|
|