igor7

Forum Replies Created

Viewing 30 posts - 31 through 60 (of 66 total)
  • Author
    Posts
  • Avatar
    igor7
    Member
    in reply to: mapdrive using Inputbox for a pc name #295054

    Re: mapdrive using Inputbox for a pc name

    Rems,
    Thank you very much!! Now both scripts works perfect!!

    1RealTruth;151811 wrote:
    How come everyone uses Static scripts?

    I put this script on the web, so everyone can download and use it (I also wrote a note how, when and why it can be helpful.)

    Avatar
    igor7
    Member
    in reply to: mapdrive using Inputbox for a pc name #295053

    Re: mapdrive using Inputbox for a pc name

    BTW, when I searched for solution I found other topic with MappingWithCredentials.HTA script (thanks Rems) and I adapted it according to my needs, so it doing the same job as previous script. Here is the code:

    Code:
    [COLOR=#555a5f][FONT=Verdana][/FONT][/COLOR]
    [FONT=Verdana][COLOR=#555a5f][/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f]Map Your Home Directory As “P” Drive[/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f][/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f][/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f]Sub Window_Onload[/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f]’# Size Window[/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f]sHorizontal = 440[/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f]sVertical = 175[/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f]Window.resizeTo sHorizontal, sVertical[/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f]’# Get Monitor Details[/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f]Set objWMIService = GetObject _[/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f] (“winmgmts:rootcimv2”)[/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f]intHorizontal = sHorizontal *2[/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f]intVertical = sVertical *2[/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f]Set colItems = objWMIService.ExecQuery( _[/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f] “Select ScreenWidth, ScreenHeight from” _[/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f] & ” Win32_DesktopMonitor”, , 48)[/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f]For Each objItem In colItems[/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f] sWidth= objItem.ScreenWidth[/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f] sHeight = objItem.ScreenHeight[/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f] If sWidth > sHorizontal _[/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f] then intHorizontal = sWidth[/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f] If sHeight > sVertical _[/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f] then intVertical = sHeight[/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f]Next[/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f]Set objWMIService = Nothing[/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f]’# Center window on the screen[/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f]intLeft = (intHorizontal – sHorizontal) /2[/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f]intTop = (intVertical – sVertical) /2[/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f]Window.moveTo intLeft, intTop[/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f]’# default window content[/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f]window.location.href=”#Top”[/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f]End Sub[/COLOR][/FONT]

    [FONT=Verdana][COLOR=#555a5f]Sub RunScript[/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f]on Error Resume Next[/COLOR][/FONT]

    [FONT=Verdana][COLOR=#555a5f]’ *** variables[/COLOR][/FONT]

    [FONT=Verdana][COLOR=#555a5f]mDrive = “P:”[/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f]strUsr = UsrnameArea.Value[/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f]strRemoteShare = strUsr & “$”[/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f]strRemoteShare = “\London” & strRemoteShare & “”[/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f]strDriveAlias = “My Home Drive”[/COLOR][/FONT]

    [FONT=Verdana][COLOR=#555a5f]minUSRnamelength = 2[/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f]minPASSwrdlength = 7[/COLOR][/FONT]

    [FONT=Verdana][COLOR=#555a5f]’ *** Map drive using the entered credentials[/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f]strUsr = UsrnameArea.Value[/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f]strPas = PasswordArea.Value[/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f]Set objNetwork = CreateObject(“WScript.Network”)[/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f]Set oShell = CreateObject(“Shell.Application”)[/COLOR][/FONT]
    [COLOR=#555a5f][FONT=Verdana]Err.Clear : objNetwork.RemoveNetworkDrive “P:”, True, True[/FONT][/COLOR]
    [FONT=Verdana][COLOR=#555a5f]If Err.Number = 0 Then Msgbox “Station P: succesfully disconnected”[/COLOR][/FONT]
    [COLOR=#555a5f][FONT=Verdana]If Len(strUsr) >= minUSRnamelength then[/FONT][/COLOR]
    [FONT=Verdana][COLOR=#555a5f]If Len(strPas) >= minPASSwrdlength then[/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f]Err.Clear[/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f]objNetwork.MapNetworkDrive mDrive, strRemoteShare, FALSE, strUsr, strPas[/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f]If Err.Number = 0 Then[/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f]oShell.NameSpace(mDrive).Self.Name = strDriveAlias[/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f]Msgbox chr(34) & strUsr & “”” Home directory is connected now!”[/COLOR][/FONT]
    [COLOR=#555a5f][FONT=Verdana]End If[/FONT][/COLOR]
    [FONT=Verdana][COLOR=#555a5f]ELSE [/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f]Msgbox “You typed an incorrect password !”[/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f]Exit Sub[/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f]End If[/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f]ELSE [/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f]Msgbox chr(34) & strUsr & “”” is an incorrect Username !”[/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f]Exit Sub[/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f]End If[/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f]Set oShell = Nothing[/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f]Set objNetwork = Nothing[/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f]Self.Close()[/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f]End Sub[/COLOR][/FONT]

    [FONT=Verdana][COLOR=#555a5f]Sub CancelScript[/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f]Set oShell = Nothing[/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f]Set objNetwork = Nothing[/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f]Self.Close()[/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f]End Sub[/COLOR][/FONT]

    [FONT=Verdana][COLOR=#555a5f][/COLOR][/FONT]

    [FONT=Verdana][COLOR=#555a5f][/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f][/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f]

    [/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f]

    [/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f]

    [/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f]

    [/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f]

    [/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f]

    [/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f]

    [/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f]

    [/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f]

    Your Username

    [/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f]

      
    [/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f]

    Company Password

    [/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f]

      

    [/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f]


    [/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f][/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f]    [/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f][/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f][/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f][/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f][/COLOR][/FONT]

    This script work good, but always return error message after I hit OK on this message box:

    Code:
    Msgbox chr(34) & strUsr & “”” Home directory is connected now!”

    Here the error code:

    Quote:



    mshta.exe – Application Error



    The instruction at “0x026c1c7d” referenced memory at “0x026d5000”. The required data was not placed into memory because of an I/O error status of “0xc00000c4”.

    Click on OK to terminate the program



    OK


    But if I remove acknowledge message about disconnected P drive:

    Code:
    If Err.Number = 0 Then Msgbox “Station P: succesfully disconnected”

    Script working perfectly. How I can avoid this error message pop up?

    Avatar
    igor7
    Member
    in reply to: mapdrive using Inputbox for a pc name #295052

    Re: mapdrive using Inputbox for a pc name

    OK… I worked on this issue and wrote working code. Here is it:

    Code:
    [COLOR=#555a5f][FONT=Verdana]If Instr(1, WScript.FullName, “wscript.exe”, vbTextCompare) then[/FONT][/COLOR]
    [FONT=Verdana][COLOR=#555a5f]boxTitle = “Map users home directory as drive [V:]”[/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f]Set WshShell = WScript.CreateObject(“WScript.Shell”)[/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f]WshShell.run “%windir%system32Cscript.exe //NoLogo “”” _[/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f] & WScript.ScriptFullName & “”””,,FALSE[/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f]Wscript.quit[/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f]End If[/COLOR][/FONT]
    [COLOR=#555a5f][FONT=Verdana]Dim objNetwork [/FONT][/COLOR]
    [FONT=Verdana][COLOR=#555a5f]Dim strDriveLetter, strRemotePath, strUser, strPassword, strPCName, strRemoteShare[/COLOR][/FONT]
    [COLOR=#555a5f][FONT=Verdana]’ Values of variables set[/FONT][/COLOR]
    [FONT=Verdana][COLOR=#555a5f]strPCName = “London”[/COLOR][/FONT]
    [COLOR=#555a5f][FONT=Verdana]WScript.StdOut.Write “Please enter your username:”[/FONT][/COLOR]
    [FONT=Verdana][COLOR=#555a5f]strRemoteShare = WScript.StdIn.ReadLine[/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f]Wscript.Echo[/COLOR][/FONT]
    [COLOR=#555a5f][FONT=Verdana]strDriveLetter = “P:” [/FONT][/COLOR]
    [FONT=Verdana][COLOR=#555a5f]strRemotePath = “\” & strPCName & “” & strRemoteShare & “$” & “”[/COLOR][/FONT]

    [FONT=Verdana][COLOR=#555a5f]strUser = strRemoteShare[/COLOR][/FONT]
    [COLOR=#555a5f][FONT=Verdana]With CreateObject(“ScriptPW.Password”)[/FONT][/COLOR]
    [FONT=Verdana][COLOR=#555a5f]WScript.StdOut.Write “Please enter your password:”[/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f]strPassword = .GetPassword()[/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f]End With[/COLOR][/FONT]
    [COLOR=#555a5f][FONT=Verdana]Set objNetwork = WScript.CreateObject(“WScript.Network”)[/FONT][/COLOR]
    [FONT=Verdana][COLOR=#555a5f]Err.Clear : objNetwork.RemoveNetworkDrive “P:”, True, True[/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f]If Err.Number = 0 Then Msgbox “Station P: succesfully disconnected” [/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f]objNetwork.MapNetworkDrive strDriveLetter, strRemotePath, false, strUser, strPassword[/COLOR][/FONT]

    [FONT=Verdana][COLOR=#555a5f]Wscript.Echo : Wscript.Echo[/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f]WScript.StdOut.Write chr(34) & strUser & “”” P drive is connected now!” : Wscript.Echo[/COLOR][/FONT]

    [FONT=Verdana][COLOR=#555a5f]WScript.StdOut.Write “Press Enter to quit” : Wscript.Echo[/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f]WScript.StdIn.ReadLine[/COLOR][/FONT]

    This script disconnect currently logged in user P drive and connect P drive of user, which ran this script and provided his credential. But still it has small limitation… If currently logged in user disconnect his P drive manually (right click on My computer >> Disconnect network drive…) script not working i.e. it not maps new user P drive. My assumption that problem somewhere here:

    Code:
    [COLOR=#555a5f][FONT=Verdana]Set objNetwork = WScript.CreateObject(“WScript.Network”)[/FONT][/COLOR]
    [FONT=Verdana][COLOR=#555a5f]Err.Clear : objNetwork.RemoveNetworkDrive “P:”, True, True[/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f]If Err.Number = 0 Then Msgbox “Station P: succesfully disconnected” [/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f]objNetwork.MapNetworkDrive strDriveLetter, strRemotePath, false, strUser, strPassword[/COLOR][/FONT]

    But I have no idea how to make this script work even curenly logged in user P drive was disconnected manualy…

    Avatar
    igor7
    Member
    in reply to: mapdrive using Inputbox for a pc name #295051

    Re: mapdrive using Inputbox for a pc name

    First of all I’m sorry for late replay, I was busy a little last month…

    Quote:
    The vbs script example from scripting guy’s forum must run with the cscript host!

    Can you advise me and show what exact syntax I should use to make example from scripting guy’s forum work?
    Rems,
    The code you posted is working only for current logged user, and my goal is a bit different. I give you a situation as an example when the users will use this script.
    As I said all users home directories placed on some server (London) and have hidden attribute ($). So, Mark and Jenny made the pictures from last the company event, for example. Mark downloaded the pictures to his home directory from the camera. Mark’s office is in the 4th floor and Jenny is in the 2nd. Mark came to Jenny’s office and she asked him to give/send her the pictures. So, Mark needed to go to his office, but instead of doing so he can map his home directory from Jenny’s computer (when Jenny already logged in and for technical reason can’t log off right now). Firs he disconnected Jenny’s home drive and then connects his own by running following command:
    net use P: \LondonMark$ /User: . But I’m trying to do this in more intelligent way. I want to create universal script that match to all company users. All what users need to do for mapping their home directories is provide a username and password into the text boxes and script should disconnect already existing home drive that belongs to the current logged user and map the new drive automatically based on the provided username/and password information.
    In a situation I described above Mark can connect to his home folder by running such as script, copy pictures to the Jenny’s computer and then Jenny can reconnect her home drive using some script. I’m already wrote a script (see my previous post). But the script doesn’t refer to the username and password Input Boxes. I.e. it doesn’t meter what username and password user provided, script always map home directory for current logging user (it disconnect and connect it again). I assume that I need to use some other input method such as STDin and STDout. Since I’m bad scripter (I’m just learning…) I need help to make the username and password input boxes work in proper way. And if it possible, password needs to be masked when user input it. Here is the my code for reference:

    Quote:
    Option Explicit
    Dim objNetwork
    Dim strDriveLetter, strRemotePath, strUser, strPassword, strPCName, strRemoteShare

    ‘ Values of variables set
    strPCName = “London”
    strRemoteShare = InputBox (“Please enter your username”)

    strDriveLetter = “V:”
    strRemotePath = “\” & strPCName & “” & strRemoteShare & “$” & “”
    ‘ A default for the MapNetworkDrive method is “persistent = false”

    strUser = strRemoteShare
    strPassword = InputBox (“Please enter your password:”)

    Set objNetwork = WScript.CreateObject(“WScript.Network”)
    Err.Clear : objNetwork.RemoveNetworkDrive “P:”, True, True
    objNetwork.MapNetworkDrive strDriveLetter, strRemotePath, false, strUser, strPassword

    ‘ Extra code just to add a message box
    WScript.Echo ” Launch Explorer, check: “& strDriveLetter

    WScript.Quit

    Avatar
    igor7
    Member
    in reply to: mapdrive using Inputbox for a pc name #295050

    Re: mapdrive using Inputbox for a pc name

    Hi, everyone!!
    I’m trying to create script that allows to users open their home directory from any company computers. My sample based on Rems script:

    Code:
    [COLOR=#555a5f][FONT=Verdana]Option Explicit[/FONT][/COLOR]
    [FONT=Verdana][COLOR=#555a5f]Dim objNetwork [/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f]Dim strDriveLetter, strRemotePath, strUser, strPassword, strPCName, strRemoteShare[/COLOR][/FONT]

    [FONT=Verdana][COLOR=#555a5f]’ Values of variables set[/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f]strPCName = “London”[/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f]strRemoteShare = InputBox (“Please enter your home share name with $ sign in the end:”)[/COLOR][/FONT]

    [FONT=Verdana][COLOR=#555a5f]strDriveLetter = “V:” [/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f]strRemotePath = “\” & strPCName & “” & strRemoteShare & “”[/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f]’ A default for the MapNetworkDrive method is “persistent = false”[/COLOR][/FONT]

    [FONT=Verdana][COLOR=#555a5f]strUser = InputBox (“Please enter your username:”)[/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f]strPassword = InputBox (“Please enter your password:”)[/COLOR][/FONT]

    [COLOR=#555a5f][FONT=Verdana]Set objNetwork = WScript.CreateObject(“WScript.Network”) [/FONT][/COLOR]
    Err.Clear : objNetwork.RemoveNetworkDrive “P:”, True, True
    [FONT=Verdana][COLOR=#555a5f]objNetwork.MapNetworkDrive strDriveLetter, strRemotePath, false, strUser, strPassword[/COLOR][/FONT]

    [FONT=Verdana][COLOR=#555a5f]’ Extra code just to add a message box[/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f]WScript.Echo ” Launch Explorer, check: “& strDriveLetter[/COLOR][/FONT]

    [FONT=Verdana][COLOR=#555a5f]WScript.Quit[/COLOR][/FONT]

    I need improve it a little…
    1. In our company users home directorys placed on root drive of the server (London) and associated with username, i.e. in aduc it looks like \London%username%$. How I can add $ (hidden share) parameter to strRemoteShare automatically without prompt user input it manually?
    2. Before mapping user home directory I need to disconnect already mapped drive (P) on same server. – already found solution (thx, Rems): Err.Clear : objNetwork.RemoveNetworkDrive “P:”, True, True
    3. How I can mask user password when user typing it? I am trying to use vbs script example from scripting guy’s forum:

    Code:
    Set objPassword = CreateObject(“ScriptPW.Password”)
    WScript.StdOut.Write “Please enter your password:”

    strPassword = objPassword.GetPassword()
    Wscript.Echo
    Wscript.Echo “Your password is: ” & strPassword

    But it returns “The handle is invalid” error??

    Avatar
    igor7
    Member
    in reply to: How to append time and date to file name? #295049

    Re: How to append time and date to file name?

    As always, thank you for exelent explanation!!
    Here is your script adjusted according to my company needs:

    Code:
    @echo on
    Set “SMBserver=Conroe”

    Set “altUsername=%SMBserver%Test”
    Set “altPassword=test”
    rem #start network-logon with server
    Set “initialLogon1=\%SMBserver%Users”
    Net use “%initialLogon1%” /User:%altUsername% %altPassword% /persistent:no 1>nul
    If %errorlevel% NEQ 0 (pause>nul & GOTO:EOF)
    Setlocal EnableDelayedExpansion

    for /f “Tokens=1-4 Delims=/ ” %%i in (‘date /t’) do set dt=%%i-%%j-%%k-%%l
    for /f “Tokens=1” %%i in (‘time /t’) do set tm=-%%i
    set tm=%tm::=-%
    set dtt=%dt%%tm%

    Set “destinationfolder=\LondonWMELogsWMELogs-%dtt%”
    Set “sourcefolder=\%SMBserver%Users”

    PushD “%sourcefolder%” &&(
    echo/The active dir is now: !CD!
    For %%a in (“*.txt”) Do If exist “%%a” (
    xcopy /s /c /d /i /y “%%a” “%destinationfolder%%dtt%-%%~na.*”
    rem #Deleting the original file,
    Del “%%a”
    )
    )
    PopD
    rem #Delete folders older than 10 days from destination folder
    PushD \ParisWMELogs &&(
    echo/The active dir is now: !CD!
    forfiles.exe /p . /d -10 /c “cmd.exe /c If /i @isdir==TRUE RD @file /s /q”
    rem # In case log file will be copied to destination folder, it will be deleted
    Forfiles.exe /p . /d -10 /c “cmd.exe /c If /i @isdir==False Del @file /s”
    )
    PopD
    rem #Disconnect from server
    rem (all mappings made to that server must have been deleted first with PopD)
    Net use “%initialLogon1%” /d /y 1>nul
    EndLocal

    Avatar
    igor7
    Member
    in reply to: How to append time and date to file name? #295048

    Re: How to append time and date to file name?

    Rems,
    You help is much appreciated!! I didn’t try your script yet, but I’m already have few questions :-D…
    1. In my script, that I posted two post above I used PushD and PopD command for deleting log file from source folder (otherwise script doesn’t delete it…). So what is a difference between PushD “%sourcefolder%” &&(
    from your script and PushD \ConroeUsers in my?
    2. The main purpose of this script – add time and data stamp to destination folder and file that copied over network. In your example written:

    Code:
    xcopy /s /c /d /i /y “%%a” “%destinationfolder%currentdatetime-%%~na.*”

    So, it means that I need to add into this script current date and time manually?
    In my version it added automatically:

    Code:
    :: prepare date/time stamp
    for /f “Tokens=1-4 Delims=/ ” %%i in (‘date /t’) do set dt=%%i-%%j-%%k-%%lfor /f “Tokens=1” %%i in (‘time /t’) do set tm=-%%i
    :: timestamp (yyyymmmdd-hhnnss)
    set tm=%tm::=-%
    set dtt=%dt%%tm%[/COLOR]

    Can I add this section to your script somehow?
    3. This is explanation and not a question. In script that you are posted you mention about using single user credentials for access network resources:

    Quote:
    preferable to use a suitable Domain account, for a faster logon,
    instead of a computer local account what is used in this sample.

    I know that it is preferable, but Conroe is local computer connected directly to another computer (domain member, from where I running this script), so to access local computer share I should use local user account (I created it just for this purpose).

    Avatar
    igor7
    Member
    in reply to: How to append time and date to file name? #295047

    Re: How to append time and date to file name?

    Rems;145818 wrote:
    you can try “Forfiles.exe” in a batch.

    Rems,
    I tried Forfiles.exe as you advised and it works fine for files. Here is my code:

    Code:
    @echo on
    :: Temporary mapping network drive
    net use S: \ConroeUsers /User:conroetest test
    PushD\Conroeusers
    SetLocal
    :: prepare date/time stamp
    for /f “Tokens=1-4 Delims=/ ” %%i in (‘date /t’) do set dt=%%i-%%j-%%k-%%lfor /f “Tokens=1” %%i in (‘time /t’) do set tm=-%%i
    :: timestamp (yyyymmmdd-hhnnss)
    set tm=%tm::=-%
    set dtt=%dt%%tm%
    :: directories
    Set “sourcefolder=\ConroeUsers”
    Set “destinationfolder=\LondonWMELogs”
    :: copy files
    For %%a in (“%sourcefolder%*.*”) Do If exist “%%a” (
    xcopy /s /c /d /i /y “%%a” “%destinationfolder%%dtt%-%%~na.*”
    )
    ::Deleting the original file
    if exist *.txt del *.txt
    :: Disconnect network Drive
    if exist S: net use S: /d /y
    PopD
    :: Delete files older than 10 days from destination folder
    net use o: \LondonWMELogs
    SetLocal enableextensions
    Forfiles /p o: /d -10 /c “cmd.exe /c If /i @isdir==False Del @file /s”
    EndLocal

    Forfiles.exe has some limits (not working with UNC path) and looking for last modified file attribute (and not creation date as vbs file that I posted few posts above) but doing his job well.
    I trying figure out what variable or command should I use for deleting folders in source directory and not files. This because naturally in my script I appended date and time stamp to the folder also. I. e. in script destination folder looks like:

    Code:
    [COLOR=#555a5f][FONT=Verdana]Set “destinationfolder=\LondonWMELogsWMELogs-%dtt%”[/FONT][/COLOR]

    So, in destination folder I have folders with date/time stamp as well as files within those folders.
    Please help me figure out what variable or command I should use to delete folders older than 10 days, for example.

    Avatar
    igor7
    Member

    Re: How to prevent logon script execiution on some machine?

    vonPryz;145668 wrote:
    I guess your script didn’t work, as the if statement does case sensitive string comparison. Use the /i switch for case insensitive comparisons. In addition, the computer’s name is likely to be LONDON instead of (LONDON). Parenthesis mess up the comparison too.

    Here it is!! You are right!! I used /i switch and it working. Big thanks!!The working code is:

    IF NOT /i %COMPUTERNAME% == LONDON GOTO NEXT
    %windir%system32wscript.exe //NoLogo //T:180 “%~dp0MMP.vbs”
    [/CODE][CODE]
    IF NOT /i %COMPUTERNAME% == LONDON GOTO NEXT
    %windir%system32wscript.exe //NoLogo //T:180 “%~dp0MMP.vbs”
    [/CODE]

    Avatar
    igor7
    Member
    in reply to: How to append time and date to file name? #295045

    Re: How to append time and date to file name?

    Dumber;145820 wrote:
    Can you post the source of the script?

    Here the source: http://windowsxp.mvps.org/wshdelfolder.htm

    Rems;145818 wrote:
    you can try “Forfiles.exe” in a batch.

    Thanks!! I will try this.

    Avatar
    igor7
    Member
    in reply to: How to append time and date to file name? #295044

    Re: How to append time and date to file name?

    Thanks, gforceindustries!! And sorry for late replay!

    I found this code that meets our eng. requirement:

    Code:
    ‘DelFolder.vbs – December 29, 2008

    Dim i, fso, f, f1, sf, BasePath, CalcResult, fNameArray()
    BasePath = “\ParisWMELogs”
    Set fso = CreateObject(“Scripting.FileSystemObject”)
    Set f = fso.GetFolder(BasePath)
    Set sf = f.SubFolders
    For Each f1 in sf
    CalcResult = DateDiff(“d”,f1.DateCreated,Now)
    if CalcResult > 180 then
    ReDim preserve fNameArray(i)
    fNameArray(i) = f1.Name
    i = i + 1
    end if
    Next

    For Each fName in fNameArray
    FSO.DeleteFolder(BasePath & “” & fName)
    Next

    This script deletes all folders in destination folder older than 180 days. I’m looking for bat script file doing the same.
    Thank you in advance,
    Igor.
    Avatar
    igor7
    Member

    Re: How to prevent logon script execiution on some machine?

    Rems, thank you!
    This script should be prevented from running just on one client machine. I will try it later and let you know if it’s working.
    BTW, I’m just interested, it can’t be done with IF/IF NOT command?

    Avatar
    igor7
    Member
    in reply to: How to append time and date to file name? #295042

    Re: How to append time and date to file name?

    Hi!!
    Can you, guys, help me one more time? Our engineers ask me, if it possible also provides a solution for deleting filesfolders from destination folder (\ParisWMELogs) older than 6 month? How it can be done with already existing vbs or bat file? Thank you in advance,
    Igor.

    Avatar
    igor7
    Member
    in reply to: How to append time and date to file name? #295041

    Re: How to append time and date to file name?

    Thanks guys!! It really was stupid spelling mistake!! Now it works fine!
    BTW. When I searched for solution for my problem I found useful link with explanation of possible cause of “The network name cannot be found”
    error. Here it is: http://support.microsoft.com/kb/875441. I hope it will be useful for somebody else…

    Avatar
    igor7
    Member
    in reply to: How to append time and date to file name? #295040

    Re: How to append time and date to file name?

    Hi, Rems!!
    Thank you very match for explanation!! As usual it makes sense now!
    But I still have a problem… When user attempt to run bat file for first time, it not working because it can’t connect to \ConroeUsers folder. So, for each user, who running this script first time from Marsel computer it not working, until this user not connect to Users share on Conroe manually from Run menu:

    34568ix6.jpg

    And after user connect manually everything work as expected. I’m trying avoiding such as behavior and include to the bat file command line for mapping \ConroeUsers share with appropriate user credentials (who has access to this share,- local Conroe user, that I created before). But when I running this command:

    net use R: \ConroeUsers/User:Conroetest test

    it returns me following error:

    34567xw4.jpg

    But when I running Net use R:\ConroeUsers command from cmd window it asks me for username and password and then successfully map the network drive:

    456789kb0.jpg

    I found vbs script that can map network drive with special user credential:

    Code:
    [COLOR=#555a5f][FONT=Verdana]’ MappingNetworkDrive.vbs[/FONT][/COLOR]
    [FONT=Verdana][COLOR=#555a5f]’ VBScript to map a network drive with all 5 arguments. [/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f]’ ———————————————————————-‘ [/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f]Option Explicit[/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f]Dim objNetwork [/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f]Dim strDriveLetter, strRemotePath, strUser, strPassword, strProfile[/COLOR][/FONT]
    [COLOR=#555a5f][FONT=Verdana]’ Values of variables set[/FONT][/COLOR]
    [FONT=Verdana][COLOR=#555a5f]strDriveLetter = “S:” [/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f]strRemotePath = “\ConroeUsers” [/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f]strUser = “test”[/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f]strPassword = “test”[/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f]strProfile = “false”[/COLOR][/FONT]
    [COLOR=#555a5f][FONT=Verdana]Set objNetwork = WScript.CreateObject(“WScript.Network”) [/FONT][/COLOR]
    [FONT=Verdana][COLOR=#555a5f]objNetwork.MapNetworkDrive strDriveLetter, strRemotePath, _[/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f]strProfile, strUser, strPassword[/COLOR][/FONT]

    and it works for me. Then I add to this vbs script ability execute bat within itself:

    Code:
    [COLOR=#555a5f][FONT=Verdana]’Calling bat file[/FONT][/COLOR]
    [FONT=Verdana][COLOR=#555a5f]dim shell[/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f]set shell=createobject(“wscript.shell”)[/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f]shell.run “SaveLogFile.bat”,1, True[/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f]set shell=nothing[/COLOR][/FONT]

    But as I said, I trying figure out why this command: net use R: \ConroeUsers/User:Conroetest test not working???
    Thanks for you help!!

    Avatar
    igor7
    Member
    in reply to: How to append time and date to file name? #295039

    Re: How to append time and date to file name?

    Rems,
    I need you advice one more time… The script in my previous post work fine on local computer. It provides very good solution to backup important files from one local drive to another. But… Two days ago I tried copy files from on remote computer to another and it not work (even when I do this with you original script)… This is a screenshot with error message:

    errordu5.jpg

    It looks like this bat file doesn’t accept UNC patch as destination folder… Here code of script I used:

    Code:
    [COLOR=#555a5f][FONT=Verdana]@echo on[/FONT][/COLOR]
    [COLOR=#555a5f][FONT=Verdana]SetLocal[/FONT][/COLOR]

    [COLOR=#555a5f][FONT=Verdana]:: prepare date/time stamp[/FONT][/COLOR]
    [COLOR=#555a5f][FONT=Verdana]for /f “Tokens=1-4 Delims=/ ” %%i in (‘date /t’) do set dt=%%i-%%j-%%k-%%l[/FONT][/COLOR]
    [COLOR=#555a5f][FONT=Verdana]for /f “Tokens=1” %%i in (‘time /t’) do set tm=-%%i[/FONT][/COLOR]
    [COLOR=#555a5f][FONT=Verdana]:: timestamp (yyyymmmdd-hhnnss)[/FONT][/COLOR]
    [COLOR=#555a5f][FONT=Verdana]set tm=%tm::=-%[/FONT][/COLOR]
    [COLOR=#555a5f][FONT=Verdana]set dtt=%dt%%tm%[/FONT][/COLOR]

    [COLOR=#555a5f][FONT=Verdana]:: directories[/FONT][/COLOR]
    [COLOR=#555a5f][FONT=Verdana]Set “sourcefolder=\ConroeUsers”[/FONT][/COLOR]
    [COLOR=#555a5f][FONT=Verdana]Set “destinationfolder=\ParisWMELogs-%dtt%”[/FONT][/COLOR]

    [COLOR=#555a5f][FONT=Verdana]:: copy files[/FONT][/COLOR]
    [COLOR=#555a5f][FONT=Verdana]For %%a in (“%sourcefolder%*.*”) Do If exist “%%a” ([/FONT][/COLOR]
    [COLOR=#555a5f][FONT=Verdana]xcopy /s /c /d /i /y “%%a” “%destinationfolder%%dtt%-%%~na.*”[/FONT][/COLOR]
    [COLOR=#555a5f][FONT=Verdana])[/FONT][/COLOR]
    [COLOR=#555a5f][FONT=Verdana]Pause[/FONT][/COLOR]

    [COLOR=#555a5f][FONT=Verdana]EndLocal[/FONT][/COLOR]

    And if I map \ParisWMELogs as network drive before, and use local patch as destination folder, script working just fine:

    successim7.jpg

    Here the working code:

    Code:
    [COLOR=#555a5f][FONT=Verdana]@echo on[/FONT][/COLOR]

    [COLOR=#555a5f][FONT=Verdana]SetLocal[/FONT][/COLOR]

    [COLOR=#555a5f][FONT=Verdana]:: Map Network drive[/FONT][/COLOR]
    [COLOR=#555a5f][FONT=Verdana]net use S: \ParisWMELogs[/FONT][/COLOR]

    [COLOR=#555a5f][FONT=Verdana]:: prepare date/time stamp[/FONT][/COLOR]
    [COLOR=#555a5f][FONT=Verdana]for /f “Tokens=1-4 Delims=/ ” %%i in (‘date /t’) do set dt=%%i-%%j-%%k-%%l[/FONT][/COLOR]
    [COLOR=#555a5f][FONT=Verdana]for /f “Tokens=1” %%i in (‘time /t’) do set tm=-%%i[/FONT][/COLOR]

    [COLOR=#555a5f][FONT=Verdana]:: timestamp (yyyymmmdd-hhnnss)[/FONT][/COLOR]
    [COLOR=#555a5f][FONT=Verdana]set tm=%tm::=-%[/FONT][/COLOR]
    [COLOR=#555a5f][FONT=Verdana]set dtt=%dt%%tm%[/FONT][/COLOR]

    [COLOR=#555a5f][FONT=Verdana]:: directories[/FONT][/COLOR]
    [COLOR=#555a5f][FONT=Verdana]Set “sourcefolder=\ConroeUsers”[/FONT][/COLOR]
    [COLOR=#555a5f][FONT=Verdana]Set “destinationfolder=S:MWELogs-%dtt%”[/FONT][/COLOR]

    [COLOR=#555a5f][FONT=Verdana]:: copy files[/FONT][/COLOR]
    [COLOR=#555a5f][FONT=Verdana]For %%a in (“%sourcefolder%*.*”) Do If exist “%%a” ([/FONT][/COLOR]
    [COLOR=#555a5f][FONT=Verdana]xcopy /s /c /d /i /y “%%a” “%destinationfolder%%dtt%-%%~na.*”[/FONT][/COLOR]
    [COLOR=#555a5f][FONT=Verdana])[/FONT][/COLOR]

    [COLOR=#555a5f][FONT=Verdana]:: Disconnect network Drive[/FONT][/COLOR]
    [COLOR=#555a5f][FONT=Verdana]if exist S: net use S: /d /y[/FONT][/COLOR]

    [COLOR=#555a5f][FONT=Verdana]EndLocal[/FONT][/COLOR]

    To be honest, I can live with this. I just trying to understand why…
    This is scenario I working with:
    Conroe – local computer (Windows 2000 SP4) member in workgroup WORK. It running some application, that saved log file in \ConroeUsers folder.
    Marsel – Litware domain computer (Windows XP SP3) have two NIC’s. One for communication with Conroe, and another for communication within Domain Litware. I am running script on this computer.
    Paris – Litware domain file server (Windows 2K3), where log files should be copied from Conroe computer.

    And one additional question. Because Conroe computer not Domain member, before I start using scrip above I should connect to \ConroeUsers folder from Marsel computer manually (from the Run menu), otherwise script not working… When I connect, it prompt’s me username/password of Conroe user, who have access to Users shared folder. I know that I can map \ConroeUsers also as network drive and provide user information in same line:

    net use R: \ConroeUsers/ User:ConroeUsername password

    May be it can be done differently, without mapping \ConroeUsers as network drive??

    Avatar
    igor7
    Member

    Re: Yes I am a lazy scripter… but I need few things to be done so please help

    Quote:
    2. Account change script – add a user to group (using: net user /ADD /Domain etc… )
    Following parameters:
    User name
    Group name

    ‘ This VBScript code adds a member to a group.
    ‘ —————————————————————
    ‘ From the book “Active Directory Cookbook” by Robbie Allen
    ‘ ISBN: 0-596-00466-4
    ‘ —————————————————————
    ‘ —— SCRIPT CONFIGURATION ——
    strGroupDN = “” ‘ e.g. cn=SalesGroup,ou=Groups,dc=rallencorp,dc=com
    strMemberDN = “” ‘ e.g. cn=jsmith,cn=users,dc=rallencorp,dc=com
    ‘ —— END CONFIGURATION ———
    set objGroup = GetObject(“LDAP://” & strGroupDN)
    ‘ Add a member
    objGroup.Add(“LDAP://” & strMemberDN)
    [/CODE]

    [QUOTE]3. Change password to expire, causing the user to be required to change his password[/QUOTE]
    You can adapt this code to you needs:

    [CODE]’ This VBScript code sets the flag that requires a user to change their password

    ‘ —————————————————————
    ‘ From the book “Active Directory Cookbook” by Robbie Allen
    ‘ ISBN: 0-596-00466-4
    ‘ —————————————————————

    ‘ —— SCRIPT CONFIGURATION ——
    strUserDN = “” ‘ e.g. cn=rallen,ou=Sales,dc=rallencorp,dc=com
    ‘ —— END CONFIGURATION ———

    set objUser = GetObject(“LDAP://” & strUserDN)
    objUser.Put “pwdLastSet”, 0
    objUser.SetInfo
    WScript.Echo “User must change password at next logon: ” & strUserDN[/CODE][CODE]
    ‘ This VBScript code adds a member to a group.


    ‘ From the book “Active Directory Cookbook” by Robbie Allen
    ‘ ISBN: 0-596-00466-4



    SCRIPT CONFIGURATION


    strGroupDN = “” ‘ e.g. cn=SalesGroup,ou=Groups,dc=rallencorp,dc=com
    strMemberDN = “” ‘ e.g. cn=jsmith,cn=users,dc=rallencorp,dc=com


    END CONFIGURATION


    set objGroup = GetObject(“LDAP://” & strGroupDN)
    ‘ Add a member
    objGroup.Add(“LDAP://” & strMemberDN)
    [/CODE]

    Quote:
    3. Change password to expire, causing the user to be required to change his password

    You can adapt this code to you needs:

    ‘ This VBScript code sets the flag that requires a user to change their password

    ‘ —————————————————————
    ‘ From the book “Active Directory Cookbook” by Robbie Allen
    ‘ ISBN: 0-596-00466-4
    ‘ —————————————————————

    ‘ —— SCRIPT CONFIGURATION ——
    strUserDN = “” ‘ e.g. cn=rallen,ou=Sales,dc=rallencorp,dc=com
    ‘ —— END CONFIGURATION ———

    set objUser = GetObject(“LDAP://” & strUserDN)
    objUser.Put “pwdLastSet”, 0
    objUser.SetInfo
    WScript.Echo “User must change password at next logon: ” & strUserDN[/CODE][CODE]’ This VBScript code sets the flag that requires a user to change their password


    ‘ From the book “Active Directory Cookbook” by Robbie Allen
    ‘ ISBN: 0-596-00466-4




    SCRIPT CONFIGURATION


    strUserDN = “” ‘ e.g. cn=rallen,ou=Sales,dc=rallencorp,dc=com


    END CONFIGURATION



    set objUser = GetObject(“LDAP://” & strUserDN)
    objUser.Put “pwdLastSet”, 0
    objUser.SetInfo
    WScript.Echo “User must change password at next logon: ” & strUserDN[/CODE]

    Avatar
    igor7
    Member

    Re: Outlook 2003 – Change Exchange server name with script

    First of all, thanks everybody for help!! largo, I skipped some how you first post (may be because I looking for script code and didn’t see really helpful post :oops:), but this is exactly what I searching for!! I didn’t test it yet but I pretty sure that it should work. Yesterday I took advantage of this problem and found that the key 13dbb0c8aa05101a9bb000aa002fc45a is not unique for each user, vice versa. – It same for all users. So, from here my job was easy. We have same problem like you explained. On computer, where users never log on (and make log on first time) everything work properly. This means that we don’t have recreate .prf file. We just need repoint users, who already have email account configured on local computers to different mail server.
    And finally I found solution. First of all I used script that read appropriate value from registry on computer, where users don’t have problem with Outlook 2003 client. This is a script code:

    Code:
    [FONT=Verdana][COLOR=#555a5f][COLOR=#555a5f][FONT=Verdana]’——————————–[/FONT][/COLOR]
    [FONT=Verdana][COLOR=#555a5f]’Script for reading registry value.vbs[/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f]’Author: igor7[/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f]’——————————–[/COLOR][/FONT]
    [COLOR=#555a5f][FONT=Verdana]Const HKEY_CURRENT_USER = &H80000001[/FONT][/COLOR]
    [COLOR=#555a5f][FONT=Verdana]strComputer = “.”[/FONT][/COLOR]

    [FONT=Verdana][COLOR=#555a5f]Set oReg=GetObject(“winmgmts:{impersonationLevel=impersonate}!\” & _[/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f]strComputer & “rootdefault:StdRegProv”)[/COLOR][/FONT]

    [FONT=Verdana][COLOR=#555a5f]strKeyPath = “SoftwareMicrosoftWindows NTCurrentVersionWindows Messaging SubsystemProfilesDefault Outlook Profile13dbb0c8aa05101a9bb000aa002fc45a”[/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f]strValueName = “001e6612″[/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f]oReg.GetStringValue HKEY_CURRENT_USER,strKeyPath,strValueName,strValue[/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f]Wscript.Echo “Proper value is: ” & strValue [/COLOR][/FONT]
    [/COLOR][/FONT]

    Then I used another script that adds new value to the registry on computer where users have problem. This is script code:

    Code:
    [FONT=Verdana][COLOR=#555a5f][FONT=Verdana][COLOR=#555a5f][COLOR=#555a5f][FONT=Verdana][COLOR=#555a5f][FONT=Verdana]’——————————–[/FONT][/COLOR]
    [FONT=Verdana][COLOR=#555a5f]’ Script Repoint users exchange profile to use different mail server.vbs[/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f]’Author: igor7[/COLOR][/FONT][/FONT][/COLOR]
    [COLOR=#555a5f][FONT=Verdana][COLOR=#555a5f][FONT=Verdana]’——————————–[/FONT][/COLOR][/FONT][/COLOR]
    [COLOR=#555a5f][FONT=Verdana]Const HKEY_CURRENT_USER = &H80000001[/FONT][/COLOR]
    [COLOR=#555a5f][FONT=Verdana]strComputer = “.”[/FONT][/COLOR]
    [FONT=Verdana][COLOR=#555a5f]Set objRegistry = GetObject(“winmgmts:\” & strComputer & “rootdefault:StdRegProv”)[/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f]strKeyPath = “SoftwareMicrosoftWindows NTCurrentVersionWindows Messaging SubsystemProfilesDefault Outlook Profile13dbb0c8aa05101a9bb000aa002fc45a”[/COLOR][/FONT]
    [COLOR=#555a5f][FONT=Verdana]strValueName = “001e6612″[/FONT][/COLOR]
    [FONT=Verdana][COLOR=#555a5f]strValue = “/O=Company/OU=East/cn=Configuration/cn=Servers/cn=EXC701″[/COLOR][/FONT]
    [FONT=Verdana][COLOR=#555a5f]objRegistry.SetStringValue HKEY_CURRENT_USER, strKeyPath, strValueName, strValue[/COLOR][/FONT]
    [COLOR=#555a5f][FONT=Verdana]WScript.Echo “Exchange Server name was set. Now, you can run Outlook 2003 client on you computer!”[/FONT][/COLOR]
    [/COLOR][/FONT][/COLOR][/FONT]

    That’s it! Changing just one subkey did the job!! After running this script, users start their
    Outlook 2003 client successfully and I found that additional appropriate registry subkey are created automatically! Thanks one more time to everybody for help!

    Avatar
    igor7
    Member

    Re: Outlook 2003 – Change Exchange server name with script

    I didn’t change Exchange server name and I’m not an Exchange admin. I just noticed, that user can’t use Outlook 2003 client on computers (we have multiply computer bullpen, so users can log on anywhere) because wrong Exchange Server name set in their mail account on each computer (may be it is just old Exchange Server and now users mailboxes moved to new one). For fix this problem I point users to change the Exchange Server name manually as I explained it in my first post (instead of Exchange501.litware.com need to write Exchange701.litware.com). My question is, if it is possible to make those changes via some script or registry hack.
    Thank you in advance,
    Igor.

    Avatar
    igor7
    Member

    Re: How to identify drive letter assigned to system drive.

    Quote:
    The windowsvariable is %systemdrive%

    Thank you!! I don’t now how I forgot this… Now it’s simple:

    Const HKEY_CURRENT_USER = &H80000001
    strComputer = “.”
    Set objRegistry = GetObject(“winmgmts:\” & strComputer & “rootdefault:StdRegProv”)

    strKeyPath = “SoftwareMicrosoftWindowsCurrentVersionRun”

    strValueName = “Test1”
    strValue = “%systemdrive%temptest1.cmd”
    objRegistry.SetStringValue HKEY_CURRENT_USER, strKeyPath, strValueName, strValue
    WScript.Echo “Stage1 value is set”
    [/CODE][CODE]
    Const HKEY_CURRENT_USER = &H80000001
    strComputer = “.”
    Set objRegistry = GetObject(“winmgmts:\” & strComputer & “rootdefault:StdRegProv”)

    strKeyPath = “SoftwareMicrosoftWindowsCurrentVersionRun”

    strValueName = “Test1”
    strValue = “%systemdrive%temptest1.cmd”
    objRegistry.SetStringValue HKEY_CURRENT_USER, strKeyPath, strValueName, strValue
    WScript.Echo “Stage1 value is set”
    [/CODE]

    Avatar
    igor7
    Member
    in reply to: How to append time and date to file name? #295034

    Re: How to append time and date to file name?

    Quote:
    forgot to add the datestamp to the file names (hahaha),,, < = FIXED

    I catch it!! :D Thank you buddy for help!!
    Here is my new script, works perfect!!

    @echo off
    SetLocal

    :: prepare date/time stamp
    for /f “Tokens=1-4 Delims=/ ” %%i in (‘date /t’) do set dt=%%i-%%j-%%k-%%l
    for /f “Tokens=1” %%i in (‘time /t’) do set tm=-%%i

    :: timestamp (yyyymmmdd-hhnnss)
    set tm=%tm::=-%
    set dtt=%dt%%tm%

    :: directories
    Set “sourcefolder=D:ProjectBackup files”
    Set “destinationfolder=C:Test-%dtt%”

    :: copy files
    For /f “delims=” %%a in (
    ‘Dir /a-D /b /s “%sourcefolder%*.*” 2^>nul’
    ) do If exist “%%a” (
    xcopy /s /c /d /i /y “%%a” “%destinationfolder%%dtt%-%%~na.*”

    )

    EndLocal[/CODE][CODE]@echo off
    SetLocal

    :: prepare date/time stamp
    for /f “Tokens=1-4 Delims=/ ” %%i in (‘date /t’) do set dt=%%i-%%j-%%k-%%l
    for /f “Tokens=1” %%i in (‘time /t’) do set tm=-%%i

    :: timestamp (yyyymmmdd-hhnnss)
    set tm=%tm::=-%
    set dtt=%dt%%tm%

    :: directories
    Set “sourcefolder=D:ProjectBackup files”
    Set “destinationfolder=C:Test-%dtt%”

    :: copy files
    For /f “delims=” %%a in (
    ‘Dir /a-D /b /s “%sourcefolder%*.*” 2^>nul’
    ) do If exist “%%a” (
    xcopy /s /c /d /i /y “%%a” “%destinationfolder%%dtt%-%%~na.*”

    )

    EndLocal[/CODE]

    Avatar
    igor7
    Member
    in reply to: How to append time and date to file name? #295033

    Re: How to append time and date to file name?

    Yes, all files in same folder. Actually I need to back up 3 log files of an application (user create them manually in same folder)…

    Avatar
    igor7
    Member
    in reply to: How I can Add Lots of Users to a Group using bat file #295032

    Re: How I can Add Lots of Users to a Group using bat file

    Thanks, Rems!!
    This is exactly what I need!! It works perfect!

    Avatar
    igor7
    Member
    in reply to: How I can Add Lots of Users to a Group using bat file #295031

    Re: How I can Add Lots of Users to a Group using bat file

    Thanks, Rems!
    As always,- you are the best:bowdown:!!!
    It should work, I will check it later…
    One question:
    In you’re example group, where I need add user, reside in same OU. What I need to change if this group located in some other OU?

    Avatar
    igor7
    Member
    in reply to: Printer does not map to all clients #295030

    Re: Printer does not map to all clients

    Hi, Rems!!
    Thank you very match for you post and exelent explanation. Now it make sence for me! I agree with you and I confirm that my assumption was wrong.
    Hope it can help to someone else…

    Avatar
    igor7
    Member
    in reply to: Printer does not map to all clients #295029

    Re: Printer does not map to all clients

    Thanks ]SK[ for correction! In my post I mentioned exactly this logon share (\SYSVOLPoliciesUserScriptsLogon) and you can see it from screen shot on my previous post. I will correct it.

    Avatar
    igor7
    Member
    in reply to: Printer does not map to all clients #295028

    Re: Printer does not map to all clients

    Hi, Rems!!
    First of all thank you for sharing you experience! Apropos you question if I sure, the answer is not 100% but in some configuration of GPO it is true! I wrote my post because I faced pretty same problem few weeks ago and fix it by configured “Run logon scripts synchronously” settings of GPO as Not configured. After you post I decide to repeat the same configuration on my test lab to confirm my assumption and YES, in my scenario (such as I faced few weeks ago) printer didn’t mapping trough user logon process. Note, that all GPO configuration i did on user part of GPO, computer settings of GPO not used at all. Here is screen shot of my test company AD configuration:

    47853159bu6.jpg

    Manufacturing Network folder GPO contains following files at netlogon share:

    86864567ra7.jpg

    MFShare.bat configured as logon script. Here is the settings:

    Code:
    %systemroot%regedit /s favorites.reg
    net use Z: \ParisMF
    ECHO ON
    FOR /F “DELIMS=” %%? IN (‘DIR/B/AD %TEMP%*’) DO RD/S/Q “%%~f?”
    DEL/F/A/Q %TEMP%*.*
    rd /S /Q “%TEMP%”
    mkdir %Temp%
    ECHO “Cleaning is complete”
    start MMANUFP.vbs

    As we see this script make network share mapping, clean user Temp folder and execute favorites.reg and MMANUFP.vbs. favorites.reg – redirect user IE favorites folder to user home folder on network and MMANUFP.vbs mapping printer for users:

    Code:

    ‘ Printers.vbs – Windows Logon Script.
    Set objNetwork = CreateObject(“WScript.Network”)
    objNetwork.AddWindowsPrinterConnection “\parisHPLaserJ”
    objNetwork.SetDefaultPrinter “\parisHPLaserJ”
    WScript.Echo “Check the Printers folder for mapped printer”

    And also for testing purposes I enable “Run logon scripts synchronously”
    and “Run logon scripts visible” at User ConfigurationAdministrative TemplatesSystemScripts

    So, in this configuration everything work great exclude printer mapping. And when I disable “Run logon scripts synchronously” policy or set is as not configured, printer map successfully:

    54872111wt7.jpg

    Now I tried different solution. I remove MMANUFP.vbs from logon share and line that execute it from MFShare.bat everything else I leave as is (“Run logon scripts synchronously”
    and “Run logon scripts visible” at User ConfigurationAdministrative TemplatesSystemScripts set as enabled)
    Than I created different policy for MMANUFP.vbs logon script in User ConfigurationAdministrative TemplatesSystemScripts and link it to same OU:

    11886375gq1.jpg

    And here everything work as expected: bat file from 1st GPO run visible and Printer mapping occur without any problem.
    Furthermore, if instead of MMANUFP.vbs file I create following bat file:

    Code:
    rundll32 printui.dll,PrintUIEntry /y /in /n \parisHPLaserJ

    and run it even locally on one of company computer with admin credentials, I saw the windows explorer splash screen before printer mapping. This also confirm my assumption that printer mapping depend on windows explorer.
    One more time,- it’s my IMHO, I didn’t find any info to confirm my assumption as well I didn’t find any thing that disprove it… If someone have another explanation for behavior of first logon script , let’s discus it!
    Sorry for long post (and my poor english)…
    Cheers,
    Igor.

    Avatar
    igor7
    Member
    in reply to: My Docs/Desktop redirection #295027

    Re: My Docs/Desktop redirection

    brcmadmin,
    Log into client computer where users still have offline files worked with admin credential. From run menu connect to folder that contain offline files by typing UNC path (\Server nameShare name), right click on this folder and deselect “Make Available Offline” option. This will stop file synchronization.

    Avatar
    igor7
    Member
    in reply to: Printer does not map to all clients #295026

    Re: Printer does not map to all clients

    Chandra1412,
    You need to check all GPO that are applied to users or computers in OU where you link GPO with mapping printer logon script. Maybe one of those GPO’s required that explorer.exe doesn’t start until another logon script is running. The mapping printer script will take effect only if windows explorer starts as regular on target computer. For example if you apply policy called:
    “Run logon scripts synchronously” at User/Computer ConfigurationAdministrative TemplatesSystemLogonthis will cause windows explorer to wait until logon script running. In this case you script will run but it not take effect on user account therefore printer will not be mapped. Read about here:
    http://www.microsoft.com/technet/prodtechnol/windows2000serv/reskit/gp/217.mspx?mfr=true

    Avatar
    igor7
    Member
    in reply to: Loop Back processing and mapped drives #295025

    Re: Loop Back processing and mapped drives

    If you are using loopback mode where user settings not applied trough login process to terminal services, you can use GPO filtering to those users who still need their setting will apply.
    Read here,- is pretty same situation…

Viewing 30 posts - 31 through 60 (of 66 total)