• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1027
  • Last Modified:

windows first launch

Is there a regkey (or something else) that can programaticaly be detected when Windows is launched for the first time after installation?
I have to write an application that must be aware of this 'first launch', under 2000 and above.
0
nonubik
Asked:
nonubik
  • 7
  • 3
  • 2
  • +2
1 Solution
 
Pete LongConsultantCommented:
curious how can you install your software prior to the Operating system to detect such a thing? or do you mean it can detect if you are trying to install the software on the "first run" is so there are text files created during setup that have the date and time in them you could check current date and time against the date/time in those logs but you would need to do that programatically which aint my field
0
 
nonubikAuthor Commented:
>curious how can you install your software prior to the Operating system to detect such a thing?
Imagine I have an OPK. Or that I switch windows to Audit mode and back.

> or do you mean it can detect if you are trying to install the software on the "first run"
No, I do not.


I belive my question is clear enough. So please post only pertinent comments.
Thank you very much.
0
 
Pete LongConsultantCommented:
c:\windows\setuplog.txt  has the first install date you would need to parse this out of the log programatically and tompare it to the currrent systemtime, though obviously a reboot in the first 24 hours would sort of knacker this approach :(
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
nonubikAuthor Commented:
A timestamp is not reliable as the date/time can be changed.
That's why I was hoping for a regkey.
0
 
craylordCommented:
Here was my accepted solution.

Just check the time/date stamp from c:\windows\repair\ folder. Specifically the SAM, SECURITY, or SOFTWARE files. These are created when windows is first installed.

http://www.experts-exchange.com/Operating_Systems/WinXP/Q_21386022.html

------------------------------------------------------------
Courtesy of mpfister in the link above.

Here is a solution for XP:

You find the date under HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\InstallDate, but its a binary value and I don't know how to convert it. Or you use a VBScript:

-------------------------------------------------------------
' Script to retrive OS Installation date and time
Option Explicit
On Error Resume Next

Dim obj, objStdOut  

Set objStdOut = WScript.StdOut

' OS Install Date

For Each obj in GetObject("winmgmts:{impersonationLevel=impersonate}").ExecQuery(_
"Select CurrentTimeZone, InstallDate From Win32_OperatingSystem")
With CreateObject("WbemScripting.SWbemDateTime")
.Value = obj.InstallDate
objStdOut.Writeline vbcrlf & DateAdd("n", -obj.CurrentTimeZone, .GetVarDate) & vbcrlf
End With
Next
WScript.Quit()

-------------------------------------------------------------

Save the text between the lines as InstDate.vbs. Then open a prompt and run

cscript InstDate.vbs

Have fun ..:-)
0
 
nonubikAuthor Commented:
craylord, please be kind and explain me how the *heck* do you know, from the install date, if the Windows 2000/XP/etc. is being launched for the first time?

Seems I post the question in the wrong TA, as I see only windows users here, but programmers.

I'll restate my question: How to know if the current session of windows is JUST the fisrt launch after windows installs? (like the first one when it displays 'windows tour', when the user sees for the first time the windows with the desktop, start menu, etc.). Absolutely *nothing* to do with the installation time.
0
 
craylordCommented:
You can't know if session is the of windows is the first launch after windows installs. It is a "catch-22". The session would have to know the initial date, plus it would have to know if any other users existed at ANY time and logged on. The session would have absolutely no way to know if a user was created, logged on and removed from the pc. All it knows is its own session. Nothing else. It asks "Is this the first time I've logged on?".

Your example of the the Windows Tour wrong. The Windows Tour is run the first time ANY user logs on. It is not run based on the installation date like your asking or thinking. In order for you to have your program incorporated, you would be better off slipstreaming it into an XP installation, ghost, or copied to the hdd via slaving or a preboot environment.

The Windows Tour is run via the Run Once scenario through the registry, again, not based on the installation date.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/xpehelp/html/xegrfrunoncerequesttypesscenarios.asp
http://support.microsoft.com/default.aspx?scid=kb;en-us;142633
0
 
m298908Commented:
Use flag files. Two Options:

Machine First Run:
If you are creating an image, put a flag file a machine (non user specific location) such as C:\Flags\MachineFirstRun.txt.  Then you can run a script on your domain logon script (if you're on a domain) which checks for existence of this flag.  If it's there, then it's the first time the machine is running.  The second step in the script if the file exists would be to rename it or delete it all together.

User First Run:
If you are creating an image, put a flag file in a default user location so that when a new user logs in, the flag file will exist.  Repeat the above step to rename or delete the file once the condition is met.  You can store info which gets deployed to all new users logging into a system under C:\Documents and Settings\Default User\Local Settings.  This would even be immune to roaming profiles since it is the local settings directory.
0
 
nonubikAuthor Commented:
@craylord:

>Your example of the the Windows Tour wrong.
Well, it seems to be just the right example. Because now I can be more specific and say "I'd like to detect if the current window session is the first time a user (any user) logs on after the windows install".

> It is not run based on the installation date like your asking or thinking
I am NOT asking or thinking about installation date. Where have you seen this among my comments? I was just ironic.

>http://support.microsoft.com/default.aspx?scid=kb;en-us;142633
This link is for WinNT only, so no help for my question addresses 2000/XP.


@m298908:

I'm not creating any images. I just have an application that has its entry in HKCU\sowftware\microsoft\windows\currentversion\run. I need this application not to be started :
  1. In Audit mode (done by checking a Windows regkey that exists only while Audit mode)
  2. The user first login (can be done by having a my own flag regkey and check against Audit mode). But I was looking for some Windows regkey for that, too, for I think it's more reliable than having my own flag regkey (error prone if my app crashes while writing the key :o)
0
 
craylordCommented:
>Your example of the the Windows Tour wrong.
>>Well, it seems to be just the right example. Because now I can be more specific and say "I'd like to detect if the current window session is the first time a user (any user) logs on after the windows install".
  This is a much better question than your posting question. Your posting questions did not specify having users log in. Just when the pc is run for the first time. Much like getting a pc from Compaq and their software setup is finalized before any user logs in. This was my impression.

> It is not run based on the installation date like your asking or thinking
>>I am NOT asking or thinking about installation date. Where have you seen this among my comments? I was just ironic.
Your question implied your program wanted to check if Windows first run after install was happening. How is a program to do this unless there is a date check? Vice versa it's an easier deal. Windows checks for first logon, then runs a program. Not program checks and installs itself. (At least from any reg settings.)

>http://support.microsoft.com/default.aspx?scid=kb;en-us;142633
>>This link is for WinNT only, so no help for my question addresses 2000/XP.
  Yes I know, that is why it was the 2nd link. Sometimes insights or "A-ha's" can be gleened by similar information.

After your rephrased question the first link is just what you need. You would need to add the path to your setup program in this registry key.
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\runonce
Add a dword with your program path.
"c:\setup\setup.exe"
or if UNC paths are supported.
"\\server01\share\setup.exe"

Or if your program takes advantage of the all users folder and .default registry entries then you could run your program in this key
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\runonceex
0
 
nonubikAuthor Commented:
>You would need to add the path to your setup program in this registry key.

If I place my program under RunOnce, it will be run the very next time a user logs on and the regkey deleted.

I see nothing related to 'windows first launch / user login'.

But I'll just do as I said before: have my flag regkey writen every time I detect an audit mode. Check this flag. If it happens that I have the flag and there is no audit mode, I'll delete the flag regkey and consider the windows session as the 'first launch / user login'.

I have spoken.
0
 
nonubikAuthor Commented:
Hi Page Editor,

Do you see any reason why this shouldn't be PAQed?
0
 
nonubikAuthor Commented:
Thanks.
0
 
moduloCommented:
PAQed with points refunded (500)

modulo
Community Support Moderator
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

  • 7
  • 3
  • 2
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now