Jump to content

Creating Batch File -- Log on Script


cjb
 Share

Recommended Posts

We have log on script for staff. Mapping them to share. I would like to use Autoit to uninstall a program and reinstall. I have created a script that will delete a file (TrackitAudit.id) using admin credentials. However, I need to know how this incorporates into log on script, so when users log drives will be mapped and the file will delete. I am new to AutoIt and so am very confused.

Link to comment
Share on other sites

We have log on script for staff. Mapping them to share. I would like to use Autoit to uninstall a program and reinstall. I have created a script that will delete a file (TrackitAudit.id) using admin credentials. However, I need to know how this incorporates into log on script, so when users log drives will be mapped and the file will delete. I am new to AutoIt and so am very confused.

HI,

what does your logon script? Can you start an exe file from it? Would you like to save the exe on the server and then start in to delete the file or on the connecting client? Starts the logon script on client or server?

So long,

Mega

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to comment
Share on other sites

HI,

what does your logon script? Can you start an exe file from it? Would you like to save the exe on the server and then start in to delete the file or on the connecting client? Starts the logon script on client or server?

So long,

Mega

Hello,

REM ---------------------------------------------

REM company name

REM Automated Login Script

REM For Air Team

REM ---------------------------------------------

NET Time \\Domain Controller /set /yes

rem NET USE F: \\chromium\Dept

NET USE H: /DELETE

NET USE H: \\plutonium\TEAMS /persistent:no

net use t: /delete

NET USE T: \\chromium\TIMSS32 /persistent:no

NET USE Z: \\THALLIUM\SOFTWARE /PERSISTENT:NO

net use u: /delete

NET USE U: \\chromium\User2 /PERSISTENT:NO

NET USE K: /DELETE

NET USE K: \\FX02-2K\client /persistent:no

Pause

@Echo off

\\trackitent\trackit\Installers\WorkstationManager\tiwsmgr.exe /uninstall

@Echo off

Pause

:End

I would like to incorporate the delete file line before \\trackitent\trackit\Installers\WorkstationManager\tiwsmgr.exe /uninstall

Here is what I did in AutoIt:

RunAsSet("username", "NTS01", "password")

FileDelete("C:\TrackitAudit.id")

The file above is the hidden file that I would like to delete.

Link to comment
Share on other sites

RunAsSet("username", "NTS01", "password")

FileDelete("C:\TrackitAudit.id")

The file above is the hidden file that I would like to delete.

RunAsSet() only affects the Run() and RunWait() functions, not FileDelete() or anything else.

Instead of FileDelete(), try

RunWait(@ComSpec & ' /c del "c:\trackitaudit.id"')

HTH

My Projects:DebugIt - Debug your AutoIt scripts with DebugIt!
Link to comment
Share on other sites

RunAsSet() only affects the Run() and RunWait() functions, not FileDelete() or anything else.

Instead of FileDelete(), try

RunWait(@ComSpec & ' /c del "c:\trackitaudit.id"')

HTH

Thanks. Very much appreciated. Now, I am still trying to figure out how I would incorporate this into the above log on script. Would I then create an .exe file and place in batch file.

Link to comment
Share on other sites

You could do that, and that's actually what I do in mine. Another way is to call AutoIt3.exe, passing the .au3 file as a parameter. Six of one, half a dozen of the other, really.

A piece of advice: if the AutoIt program is going to be one that runs continuously while the user is logged on, do something like this (catch.exe being an autoit compiled script):

if exist "%temp%\catch.exe" del /f "%temp%\catch.exe"
copy /y \\path\toscript\catch.exe "%temp%\catch.exe"
start "Catch" "%temp%\catch.exe"

In other words, make a copy of the program in the user's temp folder and execute the copy there. This allows you to update the master copy whenever you want, and not get access denied messages when trying to update it. A little trick I had to learn the hard way.

My Projects:DebugIt - Debug your AutoIt scripts with DebugIt!
Link to comment
Share on other sites

Hello,

REM ---------------------------------------------

REM company name

REM Automated Login Script

REM For Air Team

REM ---------------------------------------------

NET Time \\Domain Controller /set /yes

rem NET USE F: \\chromium\Dept

NET USE H: /DELETE

NET USE H: \\plutonium\TEAMS /persistent:no

net use t: /delete

NET USE T: \\chromium\TIMSS32 /persistent:no

NET USE Z: \\THALLIUM\SOFTWARE /PERSISTENT:NO

net use u: /delete

NET USE U: \\chromium\User2 /PERSISTENT:NO

NET USE K: /DELETE

NET USE K: \\FX02-2K\client /persistent:no

Pause

@Echo off

\\trackitent\trackit\Installers\WorkstationManager\tiwsmgr.exe /uninstall

@Echo off

Pause

:End

I would like to incorporate the delete file line before \\trackitent\trackit\Installers\WorkstationManager\tiwsmgr.exe /uninstall

Here is what I did in AutoIt:

RunAsSet("username", "NTS01", "password")

FileDelete("C:\TrackitAudit.id")

The file above is the hidden file that I would like to delete.

first of all when you do a runasset, point your password to a var if the password is wrong, the error message will popup and show the user the incorrect one.

try this.

$password = "password"
Runasset("username", "NTS01", $password)
runwait(@comspec & ' /c ' & 'if exist c:\TrackitAudit.id del c:\trackitaudit.id /f /y','',@swhide)
RunasSet()

I think the best solution would be to do away with profile logon scripts and enable logon scripts from the GPO standpoint. The main benefit is that you can run straight Autoit scripts without having to map to the shares. and also, you login scripts are not secluded to the \\server\netlogon path.

Edited by blademonkey

---"Educate the Mind, Make Savage the Body" -Mao Tse Tung

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...