Jump to content

Logon.vbs script help


pablo472
 Share

Recommended Posts

Hi, I'm completely new to scripting and AutoIT was recommended to me.

I’m trying to copy a Logon.vbs script to the Logon scripts folder in Win 7 x64 and add a registry key using AutoIT.

When compiled, the adding of the Reg key works fine but the copying/installing of the reg file to the ScriptsLogon folder will not play ball.

So far, I’ve tried the following two scripts but to no avail. Any ideas?

;Automate copying of .VBS file from local folder to Logon script folder

;Then add a Registry DWORD with a value of 1 to enable Logon Scripts to be run

#RequireAdmin

FileInstall(".Logon.vbs", "C:\Windows\System32\GroupPolicyUserScriptsLogon")

RegWrite ("HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindowsCurrentVersionPoliciesSystem", "EnableLinkedConnections", "REG_DWORD", "00000001")

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

;Automate copying of .VBS file from local folder to Logon script folder

;Then add a Registry DWORD with a value of 1 to enable Logon Scripts to be run

#RequireAdmin

RegWrite ("HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindowsCurrentVersionPoliciesSystem", "EnableLinkedConnections", "REG_DWORD", "00000001")

Local $b = True

Local $dest = True

If $b = True & $dest = True Then FileInstall ("C:UsersPaulDesktopScriptingToolsNew folderLogon.vbs", $dest = @WindowsDir & "System32GroupPolicyUserScriptsLogon")

Regards

Link to comment
Share on other sites

  • Moderators

pablo472,

Welcome to the AutoIt forum. :)

Please do not hijack an existing thread, just start a new one - especially when there was not a lot to link your question to it. ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Please wait at least 24 hours before you bump a thread.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Line

If $b = True & $dest = True Then FileInstall ("C:\Users\Paul\Desktop\ScriptingTools\New folder\Logon.vbs", $dest = @WindowsDir & "\System32\GroupPolicy\User\Scripts\Logon\")
should read:

If $b = True And $dest = True Then FileInstall ("C:\Users\Paul\Desktop\ScriptingTools\New folder\Logon.vbs", @WindowsDir & "\System32\GroupPolicy\User\Scripts\Logon\")

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

The "&" you used is a concatenation operator, not a logical operator.

When setting parameters you never pass the name of the parameter ($dest) but just the value.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Hmmm, still no luck.

Not quite sure what I'm doing wrong:

#RequireAdmin
RegWrite ("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System", "EnableLinkedConnections", "REG_DWORD", "00000001")
Local $b = True
Local $dest = True
If $b = True And $dest = True Then FileInstall ("C:\Users\Paul\Desktop\Scripting\Newfolder\Logon.vbs", @WindowsDir & "\System32\GroupPolicy\User\Scripts\Logon\")

Even renamed and removed the space between New Folder\

Edited by pablo472
Link to comment
Share on other sites

Can you manually copy the file to @WindowsDir & "System32GroupPolicyUserScriptsLogon"?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Ok, I finally got it to work with this:

#RequireAdmin
RegWrite ("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System", "EnableLinkedConnections", "REG_DWORD", "00000001")

DllCall("kernel32.dll", "int", "Wow64DisableWow64FsRedirection", "int", 1)
Local $b = True
Local $dest = True
If $b = True And $dest = True Then FileInstall ('C:\Users\Paul\Desktop\Scripting\Newfolder\Logon.vbs', @WindowsDir & '\System32\GroupPolicy\User\Scripts\Logon\')
DllCall("kernel32.dll", "int", "Wow64EnableWow64FsRedirection", "int", 1)

Only trouble is, it doesn't actually select/enable the script as it would if you did it manually within GPedit, therefore although the script itself does as it's asked, it doesn't finish the job so to speak.

Any ideas if it's possible to get it to select/enable the script as you would manually?

Regards

Link to comment
Share on other sites

  • 1 year later...

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...