Hot answers tagged

18

As part of our logon script I have that information (and more) logged into a hidden share on a server, with one log file per user. A logoff scripts adds the time the user logged off to the same log file. Easy to set up, no cost and the information is there in an easy to read format.


9

On a non domain machine you can edit the local machine policy to run scripts at startup and shut down (this may not work in Vista Home edition). To access this go to start, run then enter gpedit.msc. In here, expand the user configuration node, then windows settings, then you will find a scripts option where you can set the location of scripts to be run at ...


8

We do this via logon script which updates the computer object's description in AD. You need to perform a custom delegation of control to allow "Authenticated Users" to write the description property of computer objects in the domain/s. Once that's done, all you need is a script that generates whatever information you want and writes the properties to the ...


6

It would be much easier if you used Group Policy Preferences to map the drives and did item-level targeting to filter drive maps by group. This is the preferred way.


6

I perfer using group policy preferences for drive and printer mapping, but it really is just the preference of the person that has to manage it. Both scripts and GPO works fine and can generally give you the same results, but GPO preference I find easier to add criteria and troubleshoot.


5

Using a User Logon Script policy will always run the script as the user. There's no getting around that. As an alternative, you could consider using a Computer Startup Script. These are excecuted as the Local System account, which will have privs roughly equivilent to a local administrator account.


5

for /f is your friend. for /f "usebackq tokens=1,2,3 delims=:" %A in (`ipconfig ^| Find "Default Gateway" ^| Findstr/N "." ^| Findstr/B "1:"`) do @if not defined MYVAR set MYVAR=%~C ...might do the trick. Edit: changed the code block to read the third value not the second, and needed to escape the pipes. You could also shorten to: for /f "usebackq ...


5

Logon scripts don't display a command prompt window whilst they are running by default, however it is possible to enable this behaviour via a GPO. The logon scripts will run whilst the explorer shell is loading. You can test the exact timing of this by adding the following to one of your scripts, which will record the time the script is run in a log file. ...


5

You could use something like the following. It reads the registry key for PowerShell. If the read is successful (return code 0), or not, you get the corresponding message box, which you can switch out for other logic you need to do--like install PowerShell if it's not detected. See the source links below for more info. Option Explicit Dim oShell Dim value ...


5

I might get down voted for this, but so be it. I've always considered logon scripts to be kind of hack'ish and try to only use them as a last resort. There are so many ways to manage systems and users these days with things like Group Policy, Group Policy Preferences, and SCCM/SMS. I mean, there's always going to be cases where there just isn't a better ...


5

You can enable auditing for account logon events. These events (including workstation unlock) will be stored in the DC's security log. There are also third party tools that can make this easier, such as True Last Logon.


4

I just write the user name (as well as other info, like date and time, some program versions and so on) into the computer description using a logon script. That way I can pull all the info from AD Users & Computers quickly and easily, and as a bonus have a good way of identifying which PCs still in AD haven't been used in a while (and are therefore most ...


4

I had to achieve the same result for similar reasons; somehow determine which machine a specific user logged in from. I wanted to know "before the fact", and couldn't change user login scripts as discussed above. I used powershell on the DC that the user was authenticating against to parse the Security event log: get-eventlog "Security" | where {$_.Message ...


4

Use the runas command. or In Windows Explorer you can right-click on the bat file and choose Run As... then enter your credentials. or You could run it from a scheduled task which lets you set credentials.


3

You have two options. One means you'll have to manually pass the password each time (not ideal), the other will let you pass with password from the batch file (but this means anyone can read the batch file and discover the password). You choose which flaw you would rather live with: Option 1 (Manual Password Entry) rem This is the test.bat file runas ...


3

Why do this with batch file gyrations when you can just link GPOs to site objects? The "bonus" being that if you add addt'l subnets or move subnets around you'll never have to edit your script. If you're looking at this being a user logon script that you want to apply only when users logon to specific computers then you'll need to look at using loopback ...


3

ShellExecute the URL.


3

Although we use powershell on our servers, we use vbscript on the clients to login. VBscript is installed by default and we use it instead of CMD batch files because of the access to wmi and specifically we use it to install all the appropriate printers.


3

Windows Vista's Task Scheduler also supports running scripts at those events. http://technet.microsoft.com/en-us/appcompat/aa906020.aspx


3

Here's one of my favorites. We've got 700+ users and various divisions and subgroups that require their own drives. We're mapping based on username currently: if %username% == [username] net use /delete Z:\ if %username% == [username] net use Z: \servername\share another is the mapping of homedrives: net use H: \homeserver\%username% ...


3

There are lots of ways to skin this. For part 2, I have a vbscript that queries group membership and returns an errorlevel that you can use in your batch. The same could be done with powershell. Here is the vbscript: 'On Error Resume Next ' GroupCheck - GjM - returns errorlevel 1 if user is member of group, else returns 0 ' EX: groupcheck.vbs ...


3

Parallel SSH (pssh) is perfectly suited to this task, it executes the same command on multiple hosts in parallel. By default pssh will use 32 parallel threads but this number can be increased if required. Output from the hosts can be logged on the machine that pssh is run from. When logging output pssh will create a text file per host, however your bash ...


3

It depends on the client OS. I've run into a lot of issues using the native drive and printer map Group Policy functions on XP clients. They just don't seem to work quite right, and the only thing worse than getting a couple "my filez is gone, halp!!!!" tickets every day is getting 300 one morning because that GPO inexplicably decided to not show up for ...


3

It is possible with Group Policy. Those folders are Known Folders and you can disable them through Group Policy. Have a read at these links: http://msdn.microsoft.com/en-us/library/windows/desktop/bb776911(v=vs.85).aspx http://technet.microsoft.com/en-us/library/dd744697(v=ws.10).aspx#WS_DisableKnownFolders ...


3

Aside from improving logon times, manageability and removing a potential security issue (depending on where the script is stored etc). I can't imagine why you'd ever want to change to group policy and group policy preferences and WMI. I don't know about you but watching that logon script window makes me feel like Matthew Broderick in War Games In all ...


2

I use Logoff Scripts fairly frequently. The user's registry is still loaded when the script runs and modifications can be made to their registry. Logoff scripts run synchronously, by design. I have logoff scripts that read from the user's registry but I've never had occasion to write. Even so, I expect it would work fine. I took your code snippet above, put ...


2

A good place to start would be to use the Resulatant Set of Policy wizard in the Group Policy management console. This will show you which Group Policies are being applied to the user. Run it with the user both in and out of the groups. This will show you which policies are being applied. Focus on the differences. If that doesn't yield anything, investigate ...


2

Logon scripts run concurrently. The documentation you linked to suggests that scripts are run consecutively "processed in [...] order": If you assign multiple scripts, the scripts are processed in the order that you specify. To move a script up in the list, click it, and then click Up. To move a script down in the list, click it, and then click Down. ...


2

Group Policy Preferences allows you to set settings such as printer and drive mappings, and filter based on a myriad of settings. This includes computer names, WMI queries, and yes, user name or group membership. Be aware that going this route may cause login delays, as the group policy accesses AD to determine group membership. Just something to keep an ...



Only top voted, non community-wiki answers of a minimum length are eligible